Skip to content

Commit

Permalink
login.tsx: Faster redirect from login to dashboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj138 committed Feb 1, 2023
1 parent 71cf54c commit 52697de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function Login() {
const [password, setPassword] = useState('');
const [errorLogin, setErrorLogin] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [isAlreadyLoggedIn, setIsAlreadyLoggedIn] = useState(false);
const router = useRouter();
const { t } = useTranslation();
const lang = router.locale ?? 'en';
Expand All @@ -44,6 +45,7 @@ export default function Login() {
}
};
if (isLoggedIn()) {
setIsAlreadyLoggedIn(true);
redirectToDashboard();
}
}, []);
Expand All @@ -64,6 +66,10 @@ export default function Login() {
});
};

if (isAlreadyLoggedIn) {
return null
}

return (
<div className="bg-bunker-800 h-screen flex flex-col justify-start px-6">
<Head>
Expand Down

0 comments on commit 52697de

Please sign in to comment.