This commit is contained in:
LeoMortari
2025-09-15 01:35:11 -03:00
parent 1abcb519a5
commit 6866acda89

View File

@@ -1,11 +1,16 @@
import { Injectable, UnauthorizedException } from '@nestjs/common'; import { Injectable, Logger, UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import type { JwtPayload } from './keycloak.strategy'; import type { JwtPayload } from './keycloak.strategy';
@Injectable() @Injectable()
export class KeycloakAuthGuard extends AuthGuard('jwt') { export class KeycloakAuthGuard extends AuthGuard('jwt') {
private readonly logger = new Logger(KeycloakAuthGuard.name);
handleRequest<TUser = JwtPayload>(err: any, user: JwtPayload): TUser { handleRequest<TUser = JwtPayload>(err: any, user: JwtPayload): TUser {
this.logger.log('KeycloakAuthGuard.handleRequest');
console.log(user);
console.log(err);
if (err || !user) { if (err || !user) {
if (err instanceof UnauthorizedException) { if (err instanceof UnauthorizedException) {
throw err; throw err;