From 296796d54797666fea4b6ea3c8974e30725c5bdb Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu Date: Sat, 27 Jan 2024 17:57:23 +0000 Subject: [PATCH 1/4] allow all sign in methods --- apps/web/pages/api/auth/signup.ts | 14 +-- apps/web/pages/signup.tsx | 168 ++++++++++++++---------------- 2 files changed, 83 insertions(+), 99 deletions(-) diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts index 2a35d20a160fa3..4d90edf60e6595 100644 --- a/apps/web/pages/api/auth/signup.ts +++ b/apps/web/pages/api/auth/signup.ts @@ -6,18 +6,8 @@ import { type RequestWithUsernameStatus } from "@calcom/features/auth/signup/use import { IS_PREMIUM_USERNAME_ENABLED } from "@calcom/lib/constants"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; -import { signupSchema } from "@calcom/prisma/zod-utils"; - -function ensureSignupIsEnabled(req: RequestWithUsernameStatus) { - const { token } = signupSchema - .pick({ - token: true, - }) - .parse(req.body); - - // Stil allow signups if there is a team invite - if (token) return; +function ensureSignupIsEnabled() { if (process.env.NEXT_PUBLIC_DISABLE_SIGNUP === "true") { throw new HttpError({ statusCode: 403, @@ -39,7 +29,7 @@ export default async function handler(req: RequestWithUsernameStatus, res: NextA // Use a try catch instead of returning res every time try { ensureReqIsPost(req); - ensureSignupIsEnabled(req); + ensureSignupIsEnabled(); /** * Im not sure its worth merging these two handlers. They are different enough to be separate. diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 4f9d6782ab54cd..52366c57663eed 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -333,8 +333,7 @@ export default function Signup({ : t("create_account")} - {/* Continue with Social Logins - Only for non-invite links */} - {token || (!isGoogleLoginEnabled && !isSAMLLoginEnabled) ? null : ( + {!isGoogleLoginEnabled && !isSAMLLoginEnabled ? null : (
@@ -345,93 +344,88 @@ export default function Signup({
)} - {/* Social Logins - Only for non-invite links*/} - {!token && ( -
- {isGoogleLoginEnabled ? ( - - ) : null} - {isSAMLLoginEnabled ? ( - + ) : null} + {isSAMLLoginEnabled ? ( + - ) : null} -
- )} + return; + } + const username = formMethods.getValues("username"); + if (!username) { + showToast("error", t("username_required")); + return; + } + localStorage.setItem("username", username); + const sp = new URLSearchParams(); + // @NOTE: don't remove username query param as it's required right now for stripe payment page + sp.set("username", username); + sp.set("email", formMethods.getValues("email")); + router.push(`${process.env.NEXT_PUBLIC_WEBAPP_URL}/auth/sso/saml` + `?${sp.toString()}`); + }}> + + {t("saml_sso")} + + ) : null} +
{/* Already have an account & T&C */}
From a27d43e629cec5610849db3198aec026b0177019 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu Date: Thu, 9 May 2024 20:58:14 +0000 Subject: [PATCH 2/4] changes --- apps/web/pages/signup.tsx | 163 +++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 83 deletions(-) diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 9c182c06088bf8..42bc514d8480d6 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -409,7 +409,7 @@ export default function Signup({ {/* Continue with Social Logins - Only for non-invite links */} - {token || (!isGoogleLoginEnabled && !isSAMLLoginEnabled) ? null : ( + {!isGoogleLoginEnabled && !isSAMLLoginEnabled ? null : (
@@ -420,91 +420,88 @@ export default function Signup({
)} - {/* Social Logins - Only for non-invite links*/} - {!token && ( -
- {isGoogleLoginEnabled ? ( - - ) : null} - {isSAMLLoginEnabled ? ( - + ) : null} + {isSAMLLoginEnabled ? ( + - ) : null} -
- )} + return; + } + const username = formMethods.getValues("username"); + if (!username) { + showToast("error", t("username_required")); + return; + } + localStorage.setItem("username", username); + const sp = new URLSearchParams(); + // @NOTE: don't remove username query param as it's required right now for stripe payment page + sp.set("username", username); + sp.set("email", formMethods.getValues("email")); + router.push( + `${process.env.NEXT_PUBLIC_WEBAPP_URL}/auth/sso/saml` + `?${sp.toString()}` + ); + }}> + + {t("saml_sso")} + + ) : null} +
{/* Already have an account & T&C */}
From 237f5d92fe910bc8804c7b703591a5ef6e7be4d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Aug 2024 12:23:13 +0530 Subject: [PATCH 3/4] update --- apps/web/pages/auth/sso/[provider].tsx | 5 ++-- apps/web/pages/signup.tsx | 33 ++++++++++++++------------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/apps/web/pages/auth/sso/[provider].tsx b/apps/web/pages/auth/sso/[provider].tsx index 8aa522667f9c8d..5ea01f8dc9b46f 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 a3d939ae4ba0f8..401e67357da250 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -428,18 +428,16 @@ export default function Signup({ : t("create_account")} - {/* Continue with Social Logins - Only for non-invite links */} - {!isGoogleLoginEnabled && !isSAMLLoginEnabled ? null : ( -
-
-
- - {t("or_continue_with")} - -
-
+
+
+
+ + {t("or_continue_with")} + +
- )} +
+
{isGoogleLoginEnabled ? ( From 4206017fe515663cc9c702a12970cf718238d4eb Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Aug 2024 12:27:40 +0530 Subject: [PATCH 4/4] add checks --- apps/web/pages/signup.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index 401e67357da250..b34bd24da0f061 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -428,16 +428,17 @@ export default function Signup({ : t("create_account")} -
-
-
- - {t("or_continue_with")} - -
+ {!isGoogleLoginEnabled && !isSAMLLoginEnabled ? null : ( +
+
+
+ + {t("or_continue_with")} + +
+
-
- + )}
{isGoogleLoginEnabled ? (