mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 15:30:56 +00:00
13 lines
403 B
TypeScript
13 lines
403 B
TypeScript
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;
|
|
}
|