mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
implement booking flow
This commit is contained in:
12
apps/edr-freight-api/src/common/resolve-auth-user-id.ts
Normal file
12
apps/edr-freight-api/src/common/resolve-auth-user-id.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
export type AuthUserPayload = { id?: string; sub?: string } | null | undefined;
|
||||
|
||||
/** Resolve IAM user id from JWT payload attached by JwtGuard. */
|
||||
export function resolveAuthUserId(user: AuthUserPayload): string {
|
||||
const id = user?.id ?? user?.sub;
|
||||
if (!id) {
|
||||
throw new UnauthorizedException('Authentication required');
|
||||
}
|
||||
return id;
|
||||
}
|
||||
Reference in New Issue
Block a user