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