fix: check location.state first

This commit is contained in:
julius 2025-03-11 08:42:44 +01:00
parent b386ee365f
commit 9996752d94
Signed by: julius
GPG Key ID: C80A63E6A5FD7092

View File

@ -39,11 +39,13 @@ export const Login = ({ onLogin }: LoginProps) => {
} }
useEffect(() => { useEffect(() => {
if (location.state) {
const queryUsername = location.state.username; const queryUsername = location.state.username;
const queryPassword = location.state.password; const queryPassword = location.state.password;
if (queryUsername) setUsername(queryUsername); if (queryUsername) setUsername(queryUsername);
if (queryPassword) setPassword(queryPassword); if (queryPassword) setPassword(queryPassword);
navigate(location.pathname, { replace: true }); navigate(location.pathname, { replace: true });
}
}, []); }, []);
return ( return (