fix(auth): preserve phone identity across add-email retries
This commit is contained in:
@@ -574,6 +574,12 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
await syncStepAccountIdentityFromPayload(payload);
|
||||
if (payload.loginVerificationRequestedAt) {
|
||||
await setState({ loginVerificationRequestedAt: payload.loginVerificationRequestedAt });
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
await setState({
|
||||
...(payload.phoneVerification || payload.loginPhoneVerification ? {
|
||||
|
||||
@@ -182,21 +182,28 @@
|
||||
}
|
||||
|
||||
const displayedEmail = normalizeStep8VerificationTargetEmail(result?.displayedEmail || resolvedEmail);
|
||||
let persistedState = latestState;
|
||||
if (typeof persistRegistrationEmailState === 'function') {
|
||||
await persistRegistrationEmailState(latestState, resolvedEmail, {
|
||||
source: 'step8_add_email',
|
||||
preserveAccountIdentity: true,
|
||||
});
|
||||
persistedState = typeof getState === 'function' ? await getState() : latestState;
|
||||
} else {
|
||||
await setState({
|
||||
email: resolvedEmail,
|
||||
step8VerificationTargetEmail: displayedEmail,
|
||||
});
|
||||
persistedState = {
|
||||
...latestState,
|
||||
email: resolvedEmail,
|
||||
step8VerificationTargetEmail: displayedEmail,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
state: {
|
||||
...latestState,
|
||||
...persistedState,
|
||||
email: resolvedEmail,
|
||||
step8VerificationTargetEmail: displayedEmail,
|
||||
},
|
||||
|
||||
@@ -263,6 +263,13 @@
|
||||
const completionPayload = {
|
||||
loginVerificationRequestedAt: result.loginVerificationRequestedAt || null,
|
||||
};
|
||||
if (currentIdentifierType === 'phone') {
|
||||
completionPayload.accountIdentifierType = 'phone';
|
||||
completionPayload.accountIdentifier = currentPhoneNumber;
|
||||
completionPayload.signupPhoneNumber = currentPhoneNumber;
|
||||
completionPayload.signupPhoneCompletedActivation = currentState?.signupPhoneCompletedActivation || null;
|
||||
completionPayload.signupPhoneActivation = currentState?.signupPhoneActivation || null;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(result || {}, 'skipLoginVerificationStep')) {
|
||||
completionPayload.skipLoginVerificationStep = Boolean(result.skipLoginVerificationStep);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user