feat(connected-accounts): email-merge confirmation via emailed one-time code

When linking an email that belongs to another account, the backend now mails a
one-time code to it (merge_verification='email_code') instead of asking for that
account's password. Add a 6-digit code step: on the email_code response show the
code input, verify via authApi.verifyEmailMerge → on success redirect to /merge.
Preview/execute already go through apiClient (JWT), so they satisfy the new
initiator-bound merge endpoints. i18n in ru/en/zh/fa.
This commit is contained in:
c0mrade
2026-06-04 19:06:54 +03:00
parent c6fc167d80
commit 3224320095
6 changed files with 186 additions and 63 deletions

View File

@@ -87,7 +87,10 @@ export const authApi = {
message: string;
email?: string;
merge_required?: boolean;
merge_token?: string;
// 'email_code' means the email belongs to another account: a confirmation
// code was mailed to it and must be verified before a merge token is issued.
merge_verification?: 'email_code';
merge_token?: string | null;
}> => {
const response = await apiClient.post('/cabinet/auth/email/register', {
email,
@@ -97,6 +100,14 @@ export const authApi = {
return response.data;
},
// Confirm an email account merge with the code sent to the existing account.
verifyEmailMerge: async (
code: string,
): Promise<{ message: string; merge_required?: boolean; merge_token?: string }> => {
const response = await apiClient.post('/cabinet/auth/email/merge/verify', { code });
return response.data;
},
registerEmailStandalone: async (data: {
email: string;
password: string;