From 1b9e5f7acefbc7d0fcfdafffc708091907f6e5b3 Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Fri, 26 Sep 2025 08:48:04 +0530 Subject: [PATCH] auth fix --- src/auth/auth.service.ts | 22 +++++++++++----------- src/guards/jwt-auth.guard.ts | 3 +++ src/main.ts | 7 ++++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 1a40a60..b0f7b14 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -305,22 +305,22 @@ export class AuthService { // throw new BadRequestException("Invalid username or password") // } - if (access_token && refresh_token && userSession.length > 0) { + // if (access_token && refresh_token && userSession.length > 0) { - const getSub: any = jwt.decode(refresh_token, { complete: true }) + // const getSub: any = jwt.decode(refresh_token, { complete: true }) - const user: any = await this.getUserDetailsById(getSub?.payload.sub) + // const user: any = await this.getUserDetailsById(getSub?.payload.sub) - if (user.email !== username) { - throw new UnauthorizedException("Authentication failed") - } + // if (user.email !== username) { + // throw new UnauthorizedException("Authentication failed") + // } - let tokens = await this.getTokenFromRefreshToken(req); - const decoded = jwt.decode(access_token, { complete: true }); - const email: any = (decoded && typeof decoded === 'object') ? (decoded as any).payload?.email : undefined; - return { ...tokens, email, ApplicationName: ROLE } + // let tokens = await this.getTokenFromRefreshToken(req); + // const decoded = jwt.decode(access_token, { complete: true }); + // const email: any = (decoded && typeof decoded === 'object') ? (decoded as any).payload?.email : undefined; + // return { ...tokens, email, ApplicationName: ROLE } - } + // } const response = await axios.post(this.TOKEN_URL, params, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, diff --git a/src/guards/jwt-auth.guard.ts b/src/guards/jwt-auth.guard.ts index 066eca6..7c1468f 100644 --- a/src/guards/jwt-auth.guard.ts +++ b/src/guards/jwt-auth.guard.ts @@ -25,7 +25,10 @@ export class JwtAuthGuard implements CanActivate { return true; } + console.log(request.body); + if (!token) { + console.log("token not found") throw new UnauthorizedException('Authentication failed'); } try { diff --git a/src/main.ts b/src/main.ts index a152e6b..73722a6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,7 +20,12 @@ async function bootstrap() { 'http://localhost:5173', 'https://policy.alphaomegainfosys.com', 'https://sp.alphaomegainfosys.com', - 'https://client.alphaomegainfosys.com' + 'https://policy-2.alphaomegainfosys.com', + 'https://client-2.alphaomegainfosys.com', + 'https://sp-2.alphaomegainfosys.com', + 'https://policy-1.alphaomegainfosys.com', + 'https://client-1.alphaomegainfosys.com', + 'https://sp-1.alphaomegainfosys.com', ], methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', preflightContinue: false,