fix: allow email change for unverified emails without code verification

Skip code-based flow for unverified emails — replace email directly
and send verification to the new address. Show success step immediately
instead of asking for a verification code.
This commit is contained in:
Fringg
2026-02-11 18:28:49 +03:00
parent 1d6ec70116
commit a0b10e688c
2 changed files with 13 additions and 4 deletions

View File

@@ -181,10 +181,17 @@ export default function Profile() {
// Email change mutations
const requestEmailChangeMutation = useMutation({
mutationFn: (emailAddr: string) => authApi.requestEmailChange(emailAddr),
onSuccess: () => {
onSuccess: async (data) => {
setChangeError(null);
setChangeEmailStep('code');
setResendCooldown(UI.RESEND_COOLDOWN_SEC);
if (data.expires_in_minutes === 0) {
// Unverified email was replaced directly
setChangeEmailStep('success');
const updatedUser = await authApi.getMe();
setUser(updatedUser);
} else {
setChangeEmailStep('code');
setResendCooldown(UI.RESEND_COOLDOWN_SEC);
}
},
onError: (err: { response?: { data?: { detail?: string } } }) => {
const detail = err.response?.data?.detail;