feat(auth): show resend verification panel when registering with existing unverified email

- auth.ts: catch USER_ALREADY_EXISTS and return EMAIL_ALREADY_REGISTERED (409)
- authService: map 409 with EMAIL_ALREADY_REGISTERED code to typed error
- RegisterPage: show amber warning panel + resend + go-to-login for existing emails
- translations: add emailAlreadyRegistered, emailAlreadyRegisteredMessage, goToLogin (en/de)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-31 18:44:01 +02:00
parent c736dd52f2
commit 259253e7b3
6 changed files with 129 additions and 43 deletions

View file

@ -53,14 +53,25 @@ export function createAuthRoutes(
sourceAppStore.set(body.email, body.sourceAppUrl);
}
const response = await auth.api.signUpEmail({
body: {
email: body.email,
password: body.password,
name: body.name || body.email.split('@')[0],
},
headers: c.req.raw.headers,
});
let response;
try {
response = await auth.api.signUpEmail({
body: {
email: body.email,
password: body.password,
name: body.name || body.email.split('@')[0],
},
headers: c.req.raw.headers,
});
} catch (error) {
const isUserExists =
(error as any)?.body?.code === 'USER_ALREADY_EXISTS' ||
(error as any)?.status === 'UNPROCESSABLE_ENTITY';
if (isUserExists) {
return c.json({ error: 'Email already registered', code: 'EMAIL_ALREADY_REGISTERED' }, 409);
}
throw error;
}
if (response?.user?.id) {
security.logEvent({ userId: response.user.id, eventType: 'REGISTER' });