feat(auth): add detailed logging in JwtAuthGuard and JwtStrategy for better debugging
feat(products): enhance logging in create method to track requests and user details
This commit is contained in:
@@ -10,11 +10,23 @@ export class JwtAuthGuard extends AuthGuard('jwt') {
|
||||
}
|
||||
|
||||
canActivate(context: ExecutionContext) {
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const authHeader = request.headers.authorization;
|
||||
const path = request.path;
|
||||
const method = request.method;
|
||||
console.log(`[JwtAuthGuard.canActivate] ${method} ${path}`);
|
||||
console.log(`[JwtAuthGuard.canActivate] Authorization header:`, authHeader ? 'YES' : 'NO');
|
||||
|
||||
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
||||
context.getHandler(),
|
||||
context.getClass(),
|
||||
]);
|
||||
console.log(`[JwtAuthGuard.canActivate] isPublic:`, isPublic);
|
||||
|
||||
if (isPublic) return true;
|
||||
return super.canActivate(context);
|
||||
|
||||
const result = super.canActivate(context);
|
||||
console.log(`[JwtAuthGuard.canActivate] super.canActivate result:`, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user