diff --git a/src/api/auth.ts b/src/api/auth.ts index 297fb77..4eae2be 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -78,7 +78,12 @@ export const authApi = { registerEmail: async ( email: string, password: string, - ): Promise<{ message: string; email: string }> => { + ): Promise<{ + message: string; + email?: string; + merge_required?: boolean; + merge_token?: string; + }> => { const response = await apiClient.post('/cabinet/auth/email/register', { email, password, diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 288da5c..eb09234 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -148,7 +148,12 @@ export default function Profile() { const registerEmailMutation = useMutation({ mutationFn: ({ email, password }: { email: string; password: string }) => authApi.registerEmail(email, password), - onSuccess: async () => { + onSuccess: async (response) => { + // Backend returns merge_required when email belongs to another user + if (response.merge_required && response.merge_token) { + navigate(`/merge/${response.merge_token}`, { replace: true }); + return; + } setSuccess(t('profile.emailSent')); setError(null); setEmail('');