From 08f83dd85c5ff27840b0550d1aaa7147377c5287 Mon Sep 17 00:00:00 2001 From: Alex Johansson Date: Fri, 1 Oct 2021 13:20:28 +0100 Subject: [PATCH] fix login sometimes having to login twice (#839) --- pages/auth/login.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/auth/login.tsx b/pages/auth/login.tsx index 774f451f85..fcbe84d2b6 100644 --- a/pages/auth/login.tsx +++ b/pages/auth/login.tsx @@ -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); } }