⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
feat(web): the invite screen offers the instance's other sign-in methods (#607)
Croff0c927c8314a6
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex b0206a2e..a4a93621 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -38,7 +38,8 @@ Next.js App Router, SSR (not SPA). Tailwind v4 + shadcn/ui. See root `AGENTS.md`in the order their first section comes, each named in `sections.godGroups`. The instance'sSCIM is set up in god mode; the hosted build that also sets it up per workspace adds`WorkspaceScimSection` through `useWorkspaceSections`. `SignInExtras` sits among the sign-in methods, after the- instance's own provider; here it adds nothing, while the hosted build offers a sign-in+ instance's own provider, on the sign-in screen and on the invite screen, where it gets the+ invited address as `email`; here it adds nothing, while the hosted build offers a sign-inthrough providers of its own. A sign-in that comes back with a code the core does notknow shows the text the build's messages give it under `auth.errors.codes.<code>`.`GodSectionExtras` renders at the end of every god section page, by its slug, for settings the hosted build adds to an existing section; `WorkspaceSectionExtras`diff --git a/apps/web/src/ce/SignInExtras.tsx b/apps/web/src/ce/SignInExtras.tsxindex 845bae02..69f1ac25 100644--- a/apps/web/src/ce/SignInExtras.tsx+++ b/apps/web/src/ce/SignInExtras.tsx@@ -1,7 +1,8 @@'use client';-// Among the sign-in methods, after the instance's own provider. A self-hosted instance-// adds nothing; the hosted build offers a sign-in through providers of its own.-export default function SignInExtras(_props: { pending: boolean }) {+// Among the sign-in methods, after the instance's own provider, and on the invite screen,+// where `email` is the invited address. A self-hosted instance adds nothing; the hosted+// build offers a sign-in through providers of its own.+export default function SignInExtras(_props: { pending: boolean; email?: string }) {return null;}diff --git a/apps/web/src/features/auth/components/login/AuthLoginAlternatives.tsx b/apps/web/src/features/auth/components/login/AuthLoginAlternatives.tsxindex 30d386fd..46391ef6 100644--- a/apps/web/src/features/auth/components/login/AuthLoginAlternatives.tsx+++ b/apps/web/src/features/auth/components/login/AuthLoginAlternatives.tsx@@ -10,18 +10,21 @@ import { useAuthConfig } from '@/services/authConfig.service';// The sign-in methods that are not the email + password form: the magic link toggle,// the instance's own OIDC provider, Google, and passkeys. Which of the first three-// show depends on the instance config.+// show depends on the instance config. The invite screen has no magic link toggle, and+// passes the invited address as `email`.export default function AuthLoginAlternatives({- signingInWithLink,+ signingInWithLink = false,pending,+ email,onToggleMethod,onOidc,onGoogle,onPasskey,}: {- signingInWithLink: boolean;+ signingInWithLink?: boolean;pending: boolean;- onToggleMethod: () => void;+ email?: string;+ onToggleMethod?: () => void;onOidc: () => void;onGoogle: () => void;onPasskey: () => void;@@ -37,7 +40,7 @@ export default function AuthLoginAlternatives({// they are one stack of choices, not separate answers.return (<Field className="gap-2">- {authConfig?.magicLink && passwordEnabled && (+ {onToggleMethod && authConfig?.magicLink && passwordEnabled && (<Button type="button" variant="outline" disabled={pending} onClick={onToggleMethod}>{signingInWithLink ? <Lock /> : <Mail />}{signingInWithLink ? t('withPassword') : t('withLink')}@@ -51,7 +54,7 @@ export default function AuthLoginAlternatives({{authConfig.oidcLabel || t('withSso')}</Button>)}- <SignInExtras pending={pending} />+ <SignInExtras pending={pending} email={email} />{authConfig?.google && (<Button type="button" variant="outline" onClick={onGoogle} disabled={pending}><GoogleIcon className="size-4" />diff --git a/apps/web/src/features/auth/services/auth.service.ts b/apps/web/src/features/auth/services/auth.service.tsindex 6a1fab26..d713cd4f 100644--- a/apps/web/src/features/auth/services/auth.service.ts+++ b/apps/web/src/features/auth/services/auth.service.ts@@ -115,15 +115,16 @@ export async function resendVerificationEmail(email: string): Promise<void> {// Starts the Google round trip. Unlike every other call here this one navigates away// instead of returning a result: better-auth redirects to Google, and Google comes// back to the API callback, which then sends the browser to one of these two URLs.-// Both must be on the web origin — the handler runs on the API origin.+// Both must be on the web origin — the handler runs on the API origin. `returnTo` is a+// web path both lead to instead, the invite screen for an invitee.//// It covers sign-up as well: an unknown address gets an account, subject to the// instance registration mode, and a known one signs into the account it belongs to.-export async function signInWithGoogle(): Promise<void> {+export async function signInWithGoogle(returnTo?: string): Promise<void> {const result = await signIn.social({provider: 'google',- callbackURL: appUrl('/'),- errorCallbackURL: appUrl('/login'),+ callbackURL: appUrl(returnTo ?? '/'),+ errorCallbackURL: appUrl(returnTo ?? '/login'),});if (result.error) throw new Error(result.error.message ?? '');}@@ -131,11 +132,11 @@ export async function signInWithGoogle(): Promise<void> {// Starts the round trip through the instance's own OIDC provider. Same shape as the// Google call above: it navigates away, and both callback URLs must be on the web// origin. The provider id is fixed — the instance has exactly one.-export async function signInWithOidc(): Promise<void> {+export async function signInWithOidc(returnTo?: string): Promise<void> {const result = await signIn.social({provider: 'oidc',- callbackURL: appUrl('/'),- errorCallbackURL: appUrl('/login'),+ callbackURL: appUrl(returnTo ?? '/'),+ errorCallbackURL: appUrl(returnTo ?? '/login'),});if (result.error) throw new Error(result.error.message ?? '');}diff --git a/apps/web/src/features/invite/components/InviteAuthForm.tsx b/apps/web/src/features/invite/components/InviteAuthForm.tsxindex 1ed12dd7..d0726442 100644--- a/apps/web/src/features/invite/components/InviteAuthForm.tsx+++ b/apps/web/src/features/invite/components/InviteAuthForm.tsx@@ -1,13 +1,28 @@'use client';import { useState, type FormEvent } from 'react';-import { useRouter } from 'next/navigation';+import { useRouter, useSearchParams } from 'next/navigation';import { useTranslations } from 'next-intl';import { projectPath, projectRefOf } from '@/utils/paths';import { Button } from '@/components/ui/button';-import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field';+import {+ Field,+ FieldDescription,+ FieldError,+ FieldGroup,+ FieldLabel,+ FieldSeparator,+} from '@/components/ui/field';import { Input } from '@/components/ui/input';import { registrationRefusalKey } from '@/utils/registrationRefusals';+import { useAuthConfig } from '@/services/authConfig.service';+import AuthLoginAlternatives from '@/features/auth/components/login/AuthLoginAlternatives';+import { useRedirectError } from '@/features/auth/hooks/useRedirectError';+import {+ signInWithGoogle,+ signInWithOidc,+ signInWithPasskey,+} from '@/features/auth/services/auth.service';import {InviteAuthError,isExistingAccountError,@@ -20,7 +35,9 @@ type Mode = 'register' | 'signin';// Authentication step for the invitee. The email is fixed to the invited address// (the API only lets that email accept), so it is shown read-only. A new invitee// registers and joins in one step, opening the project. An existing invitee only-// signs in — the page then shows the accept/reject step so they can decide.+// signs in — the page then shows the accept/reject step so they can decide. The other+// sign-in methods of the sign-in screen come back here, and are all there is while the+// instance has the password form off.export default function InviteAuthForm({token,email,@@ -32,7 +49,12 @@ export default function InviteAuthForm({}) {const t = useTranslations('invite');const tAuth = useTranslations('auth.errors');+ const tLogin = useTranslations('auth.login');const router = useRouter();+ const passwordEnabled = useAuthConfig()?.emailPassword !== false;+ const params = useSearchParams();+ const redirectError = useRedirectError()(params.get('error'), params.get('error_description'));+ const returnTo = `/invite/${token}`;const [mode, setMode] = useState<Mode>(hasAccount ? 'signin' : 'register');const [password, setPassword] = useState('');const [confirm, setConfirm] = useState('');@@ -91,6 +113,19 @@ export default function InviteAuthForm({}}+ async function signInOtherwise(start: () => Promise<void>, fallback = t('genericError')) {+ setError(null);+ setNotice(null);+ setPending(true);+ try {+ await start();+ router.refresh();+ } catch (err) {+ setError((err instanceof Error && err.message) || fallback);+ }+ setPending(false);+ }+let submitLabel;if (isRegister) {submitLabel = pending ? t('registering') : t('register');@@ -107,22 +142,24 @@ export default function InviteAuthForm({<FieldDescription>{t('emailHint')}</FieldDescription></Field>- <Field>- <FieldLabel htmlFor="invite-password">{t('passwordLabel')}</FieldLabel>- <Input- id="invite-password"- type="password"- autoComplete={isRegister ? 'new-password' : 'current-password'}- required- minLength={8}- value={password}- onChange={(e) => setPassword(e.target.value)}- disabled={pending}- />- {isRegister && <FieldDescription>{t('passwordHint')}</FieldDescription>}- </Field>+ {passwordEnabled && (+ <Field>+ <FieldLabel htmlFor="invite-password">{t('passwordLabel')}</FieldLabel>+ <Input+ id="invite-password"+ type="password"+ autoComplete={isRegister ? 'new-password' : 'current-password'}+ required+ minLength={8}+ value={password}+ onChange={(e) => setPassword(e.target.value)}+ disabled={pending}+ />+ {isRegister && <FieldDescription>{t('passwordHint')}</FieldDescription>}+ </Field>+ )}- {isRegister && (+ {passwordEnabled && isRegister && (<Field><FieldLabel htmlFor="invite-confirm">{t('confirmPasswordLabel')}</FieldLabel><Input@@ -139,25 +176,40 @@ export default function InviteAuthForm({)}{notice && <FieldDescription className="text-foreground">{notice}</FieldDescription>}- {error && <FieldError>{error}</FieldError>}+ {(error || redirectError) && <FieldError>{error ?? redirectError}</FieldError>}- <Field>- <Button type="submit" disabled={pending}>- {submitLabel}- </Button>- </Field>+ {passwordEnabled && (+ <>+ <Field>+ <Button type="submit" disabled={pending}>+ {submitLabel}+ </Button>+ </Field>+ <FieldSeparator>{tLogin('or')}</FieldSeparator>+ </>+ )}- <FieldDescription className="text-center">- {isRegister ? t('haveAccount') : t('needAccount')}{' '}- <button- type="button"- className="underline underline-offset-4"- onClick={() => switchMode(isRegister ? 'signin' : 'register')}- disabled={pending}- >- {isRegister ? t('switchToSignIn') : t('switchToRegister')}- </button>- </FieldDescription>+ <AuthLoginAlternatives+ pending={pending}+ email={email}+ onOidc={() => void signInOtherwise(() => signInWithOidc(returnTo))}+ onGoogle={() => void signInOtherwise(() => signInWithGoogle(returnTo))}+ onPasskey={() => void signInOtherwise(signInWithPasskey, tAuth('passkey'))}+ />++ {passwordEnabled && (+ <FieldDescription className="text-center">+ {isRegister ? t('haveAccount') : t('needAccount')}{' '}+ <button+ type="button"+ className="underline underline-offset-4"+ onClick={() => switchMode(isRegister ? 'signin' : 'register')}+ disabled={pending}+ >+ {isRegister ? t('switchToSignIn') : t('switchToRegister')}+ </button>+ </FieldDescription>+ )}</FieldGroup></form>);