mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
## 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
10 lines
289 B
TypeScript
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);
|
|
}
|