feat: add team invitation acceptance flow with email link routing
Implement end-to-end invitation acceptance: neutral entry route validates token and routes to register (new users), login (existing users), or auto-accepts (authenticated users). Handles 2FA token survival via session, email case-insensitive matching, and dedicated error pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,14 +9,28 @@ import { Spinner } from '@/components/ui/spinner';
|
||||
import AuthBase from '@/layouts/AuthLayout.vue';
|
||||
import { login } from '@/routes';
|
||||
import { store } from '@/routes/register';
|
||||
|
||||
type Props = {
|
||||
invitation?: string;
|
||||
invitationEmail?: string;
|
||||
};
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
invitation: undefined,
|
||||
invitationEmail: undefined,
|
||||
});
|
||||
|
||||
const loginUrl = props.invitation
|
||||
? `${login()}?invitation=${props.invitation}`
|
||||
: login();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AuthBase
|
||||
title="Create an account"
|
||||
description="Enter your details below to create your account"
|
||||
:title="invitation ? 'Rejoindre l\'espace de travail' : 'Create an account'"
|
||||
:description="invitation ? 'Créez votre compte pour accepter l\'invitation' : 'Enter your details below to create your account'"
|
||||
>
|
||||
<Head title="Register" />
|
||||
<Head :title="invitation ? 'Rejoindre l\'espace de travail' : 'Register'" />
|
||||
|
||||
<Form
|
||||
v-bind="store.form()"
|
||||
@@ -24,6 +38,8 @@ import { store } from '@/routes/register';
|
||||
v-slot="{ errors, processing }"
|
||||
class="flex flex-col gap-6"
|
||||
>
|
||||
<input v-if="invitation" type="hidden" name="invitation" :value="invitation" />
|
||||
|
||||
<div class="grid gap-6">
|
||||
<div class="grid gap-2">
|
||||
<Label for="name">Name</Label>
|
||||
@@ -49,7 +65,9 @@ import { store } from '@/routes/register';
|
||||
:tabindex="2"
|
||||
autocomplete="email"
|
||||
name="email"
|
||||
placeholder="email@example.com"
|
||||
:placeholder="invitationEmail ?? 'email@example.com'"
|
||||
:value="invitationEmail"
|
||||
:readonly="!!invitationEmail"
|
||||
/>
|
||||
<InputError :message="errors.email" />
|
||||
</div>
|
||||
@@ -97,7 +115,7 @@ import { store } from '@/routes/register';
|
||||
<div class="text-center text-sm text-muted-foreground">
|
||||
Already have an account?
|
||||
<TextLink
|
||||
:href="login()"
|
||||
:href="loginUrl"
|
||||
class="underline underline-offset-4"
|
||||
:tabindex="6"
|
||||
>Log in</TextLink
|
||||
|
||||
Reference in New Issue
Block a user