Function: AuthGuard()
AuthGuard(
strategyName
,options
): typeofAuthGuard
A Guard to use passport for express or fastify
Parameters
Parameter | Type |
---|---|
strategyName | string |
options | AuthGuardOptions |
Returns
typeof AuthGuard
Example
@UseGuards(AuthGuard('local'))
@Post('login')
async authenticateWithGuard(
@AuthUser() user: CredentialLookupInterface,
): Promise<AuthenticationResponseInterface> {
const token = this.issueTokenService.issueAccessToken(user.username);
return {
...user,
...token,
};
}
Defined in
packages/nestjs-authentication/src/guards/auth.guard.ts:37 (opens in a new tab)