Variable: CurrentUser
Variable: CurrentUser
constCurrentUser: (…dataOrPipes) =>ParameterDecorator
Defined in: auth-server-nest/src/decorators/current-user.decorator.ts:22
Inject the authenticated principal (set by JwtAuthGuard) into a handler.
Returns an AuthPrincipal — a discriminated union of user + service. Use
.kind to branch:
@Get(‘me’) me(@CurrentUser() p: AuthPrincipal) { if (p.kind === ‘user’) return { email: p.email }; return { clientId: p.clientId }; }
Grab a single field by passing a key. The key is not type-narrowed against the principal kind — cast at the call site if you need type safety:
@Get() list(@CurrentUser(‘id’) userId: string) { … } // only valid for user principals
Parameters
dataOrPipes
…(string | PipeTransform<any, any> | Type<PipeTransform<any, any>> | undefined)[]
Returns
ParameterDecorator