From 795a228a446093975c713074e80d755fab4fc600 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:54:13 +0530 Subject: [PATCH] fix: allow all sign in methods when being invited (#13436) * allow all sign in methods * changes * update * add checks --------- Co-authored-by: Keith Williams Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> --- apps/web/pages/auth/sso/[provider].tsx | 5 +- apps/web/pages/signup.tsx | 173 +++++++++++++------------ 2 files changed, 90 insertions(+), 88 deletions(-) diff --git a/apps/web/pages/auth/sso/[provider].tsx b/apps/web/pages/auth/sso/[provider].tsx index 8aa522667f..5ea01f8dc9 100644 --- a/apps/web/pages/auth/sso/[provider].tsx +++ b/apps/web/pages/auth/sso/[provider].tsx @@ -19,9 +19,8 @@ export default function Provider(props: SSOProviderPageProps) { const router = useRouter(); useEffect(() => { + const email = searchParams?.get("email"); if (props.provider === "saml") { - const email = searchParams?.get("email"); - if (!email) { router.push(`/auth/error?error=Email not provided`); return; @@ -33,6 +32,8 @@ export default function Provider(props: SSOProviderPageProps) { } signIn("saml", {}, { tenant: props.tenant, product: props.product }); + } else if (props.provider === "google" && email) { + signIn("google", {}, { login_hint: email }); } else { signIn(props.provider); } diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 49015ba22a..2620efd175 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -428,8 +428,7 @@ export default function Signup({ : t("create_account")} - {/* Continue with Social Logins - Only for non-invite links */} - {token || (!isGoogleLoginEnabled && !isSAMLLoginEnabled) ? null : ( + {!isGoogleLoginEnabled && !isSAMLLoginEnabled ? null : (
@@ -440,91 +439,93 @@ export default function Signup({
)} - {/* Social Logins - Only for non-invite links*/} - {!token && ( -
- {isGoogleLoginEnabled ? ( - - ) : null} - {isSAMLLoginEnabled ? ( - - ) : null} -
- )} + } + if (token) { + searchQueryParams.set("email", prepopulateFormValues?.email); + } + const url = searchQueryParams.toString() + ? `${GOOGLE_AUTH_URL}?${searchQueryParams.toString()}` + : GOOGLE_AUTH_URL; + + router.push(url); + }}> + Google + + ) : null} + {isSAMLLoginEnabled ? ( + + ) : null} +
{/* Already have an account & T&C */}