Skip to content

Commit

Permalink
Merge pull request #280 from Neeraj138/faster-redirect-from-login
Browse files Browse the repository at this point in the history
login.tsx: Faster redirect from login to dashboard.
  • Loading branch information
vmatsiiako authored Feb 2, 2023
2 parents ccb579e + 52697de commit 3ccc6e5
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 3ccc6e5

Please sign in to comment.