Files
L-Ami-Fiduciaire/resources/js/pages/auth/Register.vue
Saad Zoubir 88e5803061 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>
2026-03-27 15:16:45 +01:00

127 lines
4.4 KiB
Vue

<script setup lang="ts">
import { Form, Head } from '@inertiajs/vue3';
import InputError from '@/components/InputError.vue';
import TextLink from '@/components/TextLink.vue';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
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="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="invitation ? 'Rejoindre l\'espace de travail' : 'Register'" />
<Form
v-bind="store.form()"
:reset-on-success="['password', 'password_confirmation']"
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>
<Input
id="name"
type="text"
required
autofocus
:tabindex="1"
autocomplete="name"
name="name"
placeholder="Full name"
/>
<InputError :message="errors.name" />
</div>
<div class="grid gap-2">
<Label for="email">Email address</Label>
<Input
id="email"
type="email"
required
:tabindex="2"
autocomplete="email"
name="email"
:placeholder="invitationEmail ?? 'email@example.com'"
:value="invitationEmail"
:readonly="!!invitationEmail"
/>
<InputError :message="errors.email" />
</div>
<div class="grid gap-2">
<Label for="password">Password</Label>
<Input
id="password"
type="password"
required
:tabindex="3"
autocomplete="new-password"
name="password"
placeholder="Password"
/>
<InputError :message="errors.password" />
</div>
<div class="grid gap-2">
<Label for="password_confirmation">Confirm password</Label>
<Input
id="password_confirmation"
type="password"
required
:tabindex="4"
autocomplete="new-password"
name="password_confirmation"
placeholder="Confirm password"
/>
<InputError :message="errors.password_confirmation" />
</div>
<Button
type="submit"
class="mt-2 w-full"
tabindex="5"
:disabled="processing"
data-test="register-user-button"
>
<Spinner v-if="processing" />
Create account
</Button>
</div>
<div class="text-center text-sm text-muted-foreground">
Already have an account?
<TextLink
:href="loginUrl"
class="underline underline-offset-4"
:tabindex="6"
>Log in</TextLink
>
</div>
</Form>
</AuthBase>
</template>