Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed login error redirect and also added toast notification for sign,signout and login error #331

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/backend/src/router/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ router.get('/logout', (req: Request, res: Response) => {
res.status(500).json({ error: 'Failed to log out' });
} else {
res.clearCookie('jwt');
res.redirect('http://localhost:5173/');
res.redirect('http://localhost:5173/?status=logout');
}
});
});
Expand All @@ -60,8 +60,8 @@ router.get(
router.get(
'/google/callback',
passport.authenticate('google', {
successRedirect: CLIENT_URL,
failureRedirect: '/login/failed',
successRedirect: `${CLIENT_URL}?login=success`,
failureRedirect: `${CLIENT_URL}?login=failed`,
}),
);

Expand All @@ -73,8 +73,8 @@ router.get(
router.get(
'/github/callback',
passport.authenticate('github', {
successRedirect: CLIENT_URL,
failureRedirect: '/login/failed',
successRedirect: `${CLIENT_URL}?login=success`,
failureRedirect: `${CLIENT_URL}?login=failed`,
}),
);

Expand Down
1 change: 1 addition & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"react-toastify": "^10.0.5",
"recoil": "^0.7.7",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
Expand Down
22 changes: 22 additions & 0 deletions apps/frontend/src/screens/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import { PlayCard } from '@/components/Card';
import { useEffect } from 'react';
import { toast, ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

export const Landing = () => {
useEffect(() => {
const params = new URLSearchParams(window.location.search);

if (params.get('login') === 'failed') {
toast.error('Login failed , Please try again later');
}
if (params.get('login') === 'success') {
toast.success('Login successful');
}
if (params.get('status') === 'logout') {
toast.warning('Signout successful');
}

params.delete('login');
const newUrl = window.location.pathname + params.toString();
window.history.replaceState({}, '', newUrl);
}, []);

return (
<div className="max-w-full h-screen chess-board mt-0">
<ToastContainer autoClose={3000} />
<div className="flex flex-col md:flex-row w-full md:w-3/4 max-w-screen-lg mx-auto gap-x-4 p-4">
<img
className="rounded-md w-full md:h-3/4 hidden md:block"
Expand Down