From 5cc654d0d8df4ec3638a09273be3ed062f3480f6 Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Fri, 26 Sep 2025 09:06:22 +0530 Subject: [PATCH] fix 1 --- src/auth/auth.service.ts | 13 +++++++++++-- src/guards/jwt-auth.guard.ts | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index b0f7b14..b34cadc 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -184,7 +184,10 @@ export class AuthService { const { email } = decoded; - if (!email) throw new UnauthorizedException('Authentication failed'); + if (!email) { + console.log("introspect token no email introspectToken mt"); + + throw new UnauthorizedException('Authentication failed');} const sessionData = await this.getUserSession(email); @@ -203,7 +206,9 @@ export class AuthService { try { const uid = await this.getUserIdByEmail(email); - if (!uid) throw new UnauthorizedException('No user ID found for email.'); + if (!uid) { + throw new UnauthorizedException('No user ID found for email.'); + } const userInfoUrl = `${this.USERS_URL}/${uid}/sessions`; @@ -229,6 +234,8 @@ export class AuthService { const decodedHeader = jwt.decode(token, { complete: true }); if (!decodedHeader || typeof decodedHeader !== 'object') { + console.log("failed decode header in decodeToken mt"); + throw new UnauthorizedException("Authentication failed") } @@ -239,6 +246,8 @@ export class AuthService { const introspection = await this.introspectToken(token); if (!introspection.active) { + console.log("introspection failed in decodeToken mt"); + throw new UnauthorizedException("Authentication Failed") } diff --git a/src/guards/jwt-auth.guard.ts b/src/guards/jwt-auth.guard.ts index b8fd026..f637b3b 100644 --- a/src/guards/jwt-auth.guard.ts +++ b/src/guards/jwt-auth.guard.ts @@ -25,15 +25,17 @@ export class JwtAuthGuard implements CanActivate { return true; } - console.log(request.cookies); + // console.log(request.cookies); - console.log(token); + // console.log(token); if (!token) { console.log("token not found") throw new UnauthorizedException('Authentication failed'); } try { + console.log("entering decode token"); + const verifiedUser = await this.authService.decodeToken(token); request.user = verifiedUser; return true;