1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-18 00:19:49 +01:00
unleash.unleash/src/lib/util/extract-user.ts
Gastón Fournier dc0fe3929e
chore: make event store accept IUser (#3076)
## About the changes
Currently, we need to remember of using the email or else the username
of a user when storing into EventStore, because we don't have
[strictNullChecks](https://www.typescriptlang.org/tsconfig#strictNullChecks),
it's error-prone. Fix for a production issue: #3072

This reuses an existing function that also deals with undefined
2023-02-21 14:11:39 +00:00

10 lines
289 B
TypeScript

import { IAuthRequest, IUser } from '../server-impl';
export function extractUsernameFromUser(user: IUser): string {
return user ? user.email || user.username : 'unknown';
}
export function extractUsername(req: IAuthRequest): string {
return extractUsernameFromUser(req.user);
}