API Reference
Rockets Core API
nestjs-authentication
functions
AuthGuard

Function: AuthGuard()

AuthGuard(strategyName, options): typeof AuthGuard

A Guard to use passport for express or fastify

Parameters

ParameterType
strategyNamestring
optionsAuthGuardOptions

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)