Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Show SSO sign-up options on the registration page (#2686)
Luke Vellae692f9a01b27
diff --git a/apps/web/src/app/[locale]/(auth)/login/page.tsx b/apps/web/src/app/[locale]/(auth)/login/page.tsxindex 2072e6f40..0b68173a1 100644--- a/apps/web/src/app/[locale]/(auth)/login/page.tsx+++ b/apps/web/src/app/[locale]/(auth)/login/page.tsx@@ -2,6 +2,9 @@ import type { Metadata } from "next";import { Trans } from "react-i18next/TransWithoutContext";import { OIDCAutoSignIn } from "@/app/[locale]/(auth)/login/components/oidc-auto-sign-in";import { env } from "@/env";+import { LoginWithOIDC } from "@/features/auth/components/login-with-oidc";+import { OrDivider } from "@/features/auth/components/or-divider";+import { SSOProvider } from "@/features/auth/components/sso-provider";import { getRegistrationEnabled } from "@/features/instance-settings/data";import { getTranslation } from "@/i18n/server";import { authLib, getSessionState } from "@/lib/auth";@@ -18,9 +21,6 @@ import {import { LinkWithRedirectTo } from "../components/link-with-redirect-to";import { AuthErrors } from "./components/auth-errors";import { LoginWithEmailForm } from "./components/login-email-form";-import { LoginWithOIDC } from "./components/login-with-oidc";-import { OrDivider } from "./components/or-divider";-import { SSOProvider } from "./components/sso-provider";async function loadData() {const [isRegistrationEnabled, { t }] = await Promise.all([diff --git a/apps/web/src/app/[locale]/(auth)/register/page.tsx b/apps/web/src/app/[locale]/(auth)/register/page.tsxindex 904238c7c..334dc9880 100644--- a/apps/web/src/app/[locale]/(auth)/register/page.tsx+++ b/apps/web/src/app/[locale]/(auth)/register/page.tsx@@ -1,9 +1,13 @@import type { Metadata } from "next";import { notFound } from "next/navigation";import { Trans } from "react-i18next/TransWithoutContext";+import { env } from "@/env";+import { LoginWithOIDC } from "@/features/auth/components/login-with-oidc";+import { OrDivider } from "@/features/auth/components/or-divider";+import { SSOProvider } from "@/features/auth/components/sso-provider";import { getRegistrationEnabled } from "@/features/instance-settings/data";import { getTranslation } from "@/i18n/server";-import { redirectIfLoggedIn } from "@/lib/auth";+import { authLib, redirectIfLoggedIn } from "@/lib/auth";import {AuthPageContainer,AuthPageContent,@@ -17,9 +21,11 @@ import { RegisterNameForm } from "./components/register-name-form";export default async function Register(props: {params: Promise<{ locale: string }>;+ searchParams?: Promise<{ redirectTo?: string }>;}) {await redirectIfLoggedIn();const params = await props.params;+ const searchParams = await props.searchParams;const { t } = await getTranslation(params.locale);const isRegistrationEnabled = await getRegistrationEnabled();@@ -27,6 +33,15 @@ export default async function Register(props: {notFound();}+ const hasGoogleProvider = !!authLib.options.socialProviders.google;+ const hasMicrosoftProvider = !!authLib.options.socialProviders.microsoft;+ const hasOidc = !!authLib.options.plugins.find(+ (plugin) => plugin.id === "generic-oauth",+ );++ const hasAlternateSignUpMethods =+ hasGoogleProvider || hasMicrosoftProvider || hasOidc;+return (<AuthPageContainer><AuthPageHeader>@@ -49,6 +64,31 @@ export default async function Register(props: {</AuthPageHeader><AuthPageContent><RegisterNameForm />+ {hasAlternateSignUpMethods ? <OrDivider /> : null}+ {hasAlternateSignUpMethods ? (+ <div className="grid gap-3">+ {hasOidc ? (+ <LoginWithOIDC+ name={env.OIDC_NAME}+ redirectTo={searchParams?.redirectTo}+ />+ ) : null}+ {hasGoogleProvider ? (+ <SSOProvider+ providerId="google"+ name="Google"+ redirectTo={searchParams?.redirectTo}+ />+ ) : null}+ {hasMicrosoftProvider ? (+ <SSOProvider+ providerId="microsoft"+ name="Microsoft"+ redirectTo={searchParams?.redirectTo}+ />+ ) : null}+ </div>+ ) : null}</AuthPageContent><AuthPageExternal><Transdiff --git a/apps/web/src/app/[locale]/(auth)/login/components/login-with-oidc.tsx b/apps/web/src/features/auth/components/login-with-oidc.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(auth)/login/components/login-with-oidc.tsxrename to apps/web/src/features/auth/components/login-with-oidc.tsxdiff --git a/apps/web/src/app/[locale]/(auth)/login/components/or-divider.tsx b/apps/web/src/features/auth/components/or-divider.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(auth)/login/components/or-divider.tsxrename to apps/web/src/features/auth/components/or-divider.tsxdiff --git a/apps/web/src/app/[locale]/(auth)/login/components/sso-provider.tsx b/apps/web/src/features/auth/components/sso-provider.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/(auth)/login/components/sso-provider.tsxrename to apps/web/src/features/auth/components/sso-provider.tsx