fix login sometimes having to login twice (#839)

pull/838/head^2
Alex Johansson 2021-10-01 13:20:28 +01:00 committed by GitHub
parent 3d3e99272a
commit 08f83dd85c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -48,12 +48,12 @@ export default function Login({ csrfToken }) {
callbackUrl,
});
if (!response) {
console.error("Received empty response from next auth");
return;
throw new Error("Received empty response from next auth");
}
if (!response.error) {
router.replace(callbackUrl);
// we're logged in! let's do a hard refresh to the desired url
window.location.replace(callbackUrl);
return;
}
@ -63,9 +63,9 @@ export default function Login({ csrfToken }) {
} else {
setErrorMessage(errorMessages[response.error] || "Something went wrong.");
}
setIsSubmitting(false);
} catch (e) {
setErrorMessage("Something went wrong.");
} finally {
setIsSubmitting(false);
}
}