fix(connected-accounts): guide the user to enter the existing account's password when merging by email

The backend account-takeover fix now requires the existing account's password
before merging an email that already belongs to another account. Show a clear
message (profile.emailMergePasswordRequired) on that response instead of the
generic "already registered" dead-end, so the legitimate owner knows to enter
that account's password (in both password fields) to complete the merge. i18n
in ru/en/zh/fa.
This commit is contained in:
c0mrade
2026-06-04 14:06:45 +03:00
parent f9cc70cba3
commit 7d31dc3ffa
5 changed files with 14 additions and 5 deletions

View File

@@ -4594,7 +4594,8 @@
"vk": "VK" "vk": "VK"
}, },
"backToAccounts": "Back to accounts" "backToAccounts": "Back to accounts"
} },
"emailMergePasswordRequired": "This email already belongs to another account. To merge the accounts, enter that account's password."
}, },
"theme": { "theme": {
"colors": "Theme Colors", "colors": "Theme Colors",

View File

@@ -4139,7 +4139,8 @@
"vk": "VK" "vk": "VK"
}, },
"backToAccounts": "بازگشت به فهرست حساب‌ها" "backToAccounts": "بازگشت به فهرست حساب‌ها"
} },
"emailMergePasswordRequired": "این ایمیل قبلاً به حساب دیگری تعلق دارد. برای ادغام حساب‌ها، رمز عبور آن حساب را وارد کنید."
}, },
"theme": { "theme": {
"colors": "رنگ‌های تم", "colors": "رنگ‌های تم",

View File

@@ -5146,7 +5146,8 @@
"vk": "VK" "vk": "VK"
}, },
"backToAccounts": "К списку аккаунтов" "backToAccounts": "К списку аккаунтов"
} },
"emailMergePasswordRequired": "Этот email уже привязан к другому аккаунту. Чтобы объединить аккаунты, введите пароль от него."
}, },
"theme": { "theme": {
"colors": "Цвета темы", "colors": "Цвета темы",

View File

@@ -4138,7 +4138,8 @@
"vk": "VK" "vk": "VK"
}, },
"backToAccounts": "返回账户列表" "backToAccounts": "返回账户列表"
} },
"emailMergePasswordRequired": "该邮箱已属于另一个账户。要合并账户,请输入该账户的密码。"
}, },
"theme": { "theme": {
"colors": "主题颜色", "colors": "主题颜色",

View File

@@ -409,7 +409,12 @@ export default function ConnectedAccounts() {
}, },
onError: (err: { response?: { data?: { detail?: string } } }) => { onError: (err: { response?: { data?: { detail?: string } } }) => {
const detail = err.response?.data?.detail; const detail = err.response?.data?.detail;
if (detail?.includes('already registered')) { // The email belongs to another account and merging it requires proving
// ownership: the backend asks for THAT account's password (account-takeover
// fix). Guide the user to enter it rather than showing a dead-end error.
if (detail?.includes('merge')) {
setEmailError(t('profile.emailMergePasswordRequired'));
} else if (detail?.includes('already registered')) {
setEmailError(t('profile.emailAlreadyRegistered')); setEmailError(t('profile.emailAlreadyRegistered'));
} else if (detail?.includes('already have a verified email')) { } else if (detail?.includes('already have a verified email')) {
setEmailError(t('profile.alreadyHaveEmail')); setEmailError(t('profile.alreadyHaveEmail'));