This commit is contained in:
Kallesh B S 2025-09-26 09:06:22 +05:30
parent 3256b0a4a7
commit 5cc654d0d8
2 changed files with 15 additions and 4 deletions

View File

@ -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")
}

View File

@ -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;