From bdfdefcef85e3b948706195d5b1e6a41f2b1a5be Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Fri, 26 Sep 2025 13:16:07 +0530 Subject: [PATCH] fix 2 --- src/auth/auth.controller.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 5b27c8d..fa46ba5 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -48,11 +48,20 @@ export class AuthController { let k: any = await this.authService.loginUser(body.P_EMAILADDR.toLowerCase(), body.P_PASSWORD, body.P_APPLICATIONNAME, req, 2); + let appDomain; + if (req.headers.origin) { + appDomain = extractSubdomain(req.headers.origin) + } + else { + appDomain = "" + } + if (k.access_token) { res.cookie('access_token', k.access_token, { httpOnly: true, secure: true, - sameSite: 'none' + sameSite: 'none', + domain: `${appDomain.length > 0 ? appDomain + ".alphaomegainfosys.com" : "localhost"}` }); } @@ -60,7 +69,8 @@ export class AuthController { res.cookie('refresh_token', k.refresh_token, { httpOnly: true, secure: true, - sameSite: 'none' + sameSite: 'none', + domain: `${appDomain.length > 0 ? appDomain + ".alphaomegainfosys.com" : "localhost"}` }); } @@ -117,16 +127,25 @@ export class AuthController { async logoutb(@Req() req: any, @Res() res: Response) { const refreshToken = req.user?.refreshToken; let rst: any = await this.authService.logoutUser(refreshToken); + let appDomain; + if (req.headers.origin) { + appDomain = extractSubdomain(req.headers.origin) + } + else { + appDomain = "" + } if (rst.statusCode === 200) { res.clearCookie('access_token', { httpOnly: true, secure: true, - sameSite: 'none' + sameSite: 'none', + domain: `${appDomain.length > 0 ? appDomain + ".alphaomegainfosys.com" : "localhost"}` }); res.clearCookie('refresh_token', { httpOnly: true, secure: true, - sameSite: 'none' + sameSite: 'none', + domain: `${appDomain.length > 0 ? appDomain + ".alphaomegainfosys.com" : "localhost"}` }); } res.json({ ...rst })