mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
Merge pull request #280 from Neeraj138/faster-redirect-from-login
login.tsx: Faster redirect from login to dashboard.
This commit is contained in:
@@ -22,6 +22,7 @@ export default function Login() {
|
|||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [errorLogin, setErrorLogin] = useState(false);
|
const [errorLogin, setErrorLogin] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [isAlreadyLoggedIn, setIsAlreadyLoggedIn] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const lang = router.locale ?? 'en';
|
const lang = router.locale ?? 'en';
|
||||||
@@ -44,6 +45,7 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
|
setIsAlreadyLoggedIn(true);
|
||||||
redirectToDashboard();
|
redirectToDashboard();
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@@ -64,6 +66,10 @@ export default function Login() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isAlreadyLoggedIn) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-bunker-800 h-screen flex flex-col justify-start px-6">
|
<div className="bg-bunker-800 h-screen flex flex-col justify-start px-6">
|
||||||
<Head>
|
<Head>
|
||||||
|
|||||||
Reference in New Issue
Block a user