mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
chore: helper methods to extract user data from req (#5710)
With the recent changes it's common that we'll need both the id and processed username from the auth user in the request, so this PR provides some helper methods to simplify this.
This commit is contained in:
parent
60d3768ab1
commit
efa691d120
@ -7,3 +7,10 @@ export function extractUsernameFromUser(user: IUser): string {
|
||||
export function extractUsername(req: IAuthRequest): string {
|
||||
return extractUsernameFromUser(req.user);
|
||||
}
|
||||
|
||||
export const extractUserId = (req: IAuthRequest) => req.user.id;
|
||||
|
||||
export const extractUserInfo = (req: IAuthRequest) => ({
|
||||
id: extractUserId(req),
|
||||
username: extractUsername(req),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user