diff --git a/backend/controllers/userController.ts b/backend/controllers/userController.ts index d0066f8..94d0986 100644 --- a/backend/controllers/userController.ts +++ b/backend/controllers/userController.ts @@ -132,8 +132,8 @@ export const userLogin = asyncWrapper(async (req: Request, res: Response) => { httpOnly: true, secure: process.env.NODE_ENV === 'production', // secure: true, //for ngrok/https, its true else false - // sameSite: 'strict', - sameSite: "none", + sameSite: 'strict', + // sameSite: "none", maxAge: 5 * 24 * 60 * 60 * 1000 }); @@ -178,8 +178,8 @@ export const adminLogin = asyncWrapper(async (req, res) => { httpOnly: true, secure: process.env.NODE_ENV === 'production', // secure: true, - // sameSite: 'strict', - sameSite: "none", + sameSite: 'strict', + // sameSite: "none", maxAge: 5 * 24 * 60 * 60 * 1000 }); diff --git a/backend/routes/oauthRouter.ts b/backend/routes/oauthRouter.ts index 6243281..a3a129e 100644 --- a/backend/routes/oauthRouter.ts +++ b/backend/routes/oauthRouter.ts @@ -10,10 +10,10 @@ router.get("/login/success", successHandler); router.get("/login/failed", failureHandler); -router.get("/google", passport.authenticate("google", { scope: ["profile", "email"] })); +router.get("/google", passport.authenticate("google", { scope: ["profile", "email"], prompt: 'select_account' })); // Google OAuth callback URL -router.get('/google/callback', passport.authenticate('google', { session: false, failureRedirect:`${process.env.CLIENT_URL}/failed` }), (req, res) => { +router.get('/google/callback', passport.authenticate('google', { session: false, failureRedirect:`${process.env.CLIENT_URL}/failed`,prompt: 'select_account' }), (req, res) => { console.log("HAHAHAHAH") if (req.user) { const user: any = req.user; @@ -23,7 +23,8 @@ router.get('/google/callback', passport.authenticate('google', { session: false, // Set the cookie res.cookie('token', token, { httpOnly: true, - sameSite: 'none', + sameSite: 'strict', + // sameSite: 'none', maxAge: 5 * 24 * 60 * 60 * 1000 }); diff --git a/frontend/src/pages/auth/Login.tsx b/frontend/src/pages/auth/Login.tsx index 2f591c7..140f647 100644 --- a/frontend/src/pages/auth/Login.tsx +++ b/frontend/src/pages/auth/Login.tsx @@ -21,8 +21,8 @@ function Login() { e.preventDefault(); const callbackUrl = import.meta.env.VITE_NODE_ENV === "development" - ? "http://localhost:3000/api/oauth/google/callback" - : "/api/oauth/google/callback"; + ? "http://localhost:3000/api/oauth/google" + : "/api/oauth/google"; window.open(callbackUrl, "_self"); }; diff --git a/frontend/src/pages/auth/Signup.tsx b/frontend/src/pages/auth/Signup.tsx index 88df941..d33bdac 100644 --- a/frontend/src/pages/auth/Signup.tsx +++ b/frontend/src/pages/auth/Signup.tsx @@ -23,12 +23,13 @@ function Signup() { e.preventDefault(); const callbackUrl = import.meta.env.VITE_NODE_ENV === "development" - ? "http://localhost:3000/api/oauth/google/callback" - : "/api/oauth/google/callback"; + ? "http://localhost:3000/api/oauth/google" + : "/api/oauth/google"; window.open(callbackUrl, "_self"); }; - // // OR + +// OR // const googleAuth = (e: any) => { // e.preventDefault() // window.open(