From 203d9e4c1eeba1bf4bbb0897ff7e10956aecd159 Mon Sep 17 00:00:00 2001 From: Simon Ha Date: Mon, 6 May 2024 03:38:39 -0400 Subject: [PATCH] bug: fix sign-in when returnTo=sign-in (#24893) * bug: fix sign-in when returnTo=sign-in - default redirect to /projects instead * Update apps/studio/components/interfaces/SignIn/SignInForm.tsx --------- Co-authored-by: Alaister Young --- apps/studio/components/interfaces/SignIn/SignInForm.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/studio/components/interfaces/SignIn/SignInForm.tsx b/apps/studio/components/interfaces/SignIn/SignInForm.tsx index d1f424d6bda..f0d5bf56358 100644 --- a/apps/studio/components/interfaces/SignIn/SignInForm.tsx +++ b/apps/studio/components/interfaces/SignIn/SignInForm.tsx @@ -52,8 +52,9 @@ const SignInForm = () => { toast.success(`Signed in successfully!`, { id: toastId }) await queryClient.resetQueries() - - router.push(getReturnToPath()) + const returnTo = getReturnToPath() + // since we're already on the /sign-in page, prevent redirect loops + router.push(returnTo === '/sign-in' ? '/projects' : returnTo) } catch (error) { toast.error((error as AuthError).message, { id: toastId }) }