diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js index b468607ed8f3..e3aee93a6911 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js +++ b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js @@ -21,6 +21,7 @@ import withThemeStyles, {withThemeStylesPropTypes} from '@components/withThemeSt import compose from '@libs/compose'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as Session from '@userActions/Session'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -119,12 +120,22 @@ class ContactMethodDetailsPage extends Component { } componentDidUpdate(prevProps) { - const validatedDate = lodashGet(this.props.loginList, [this.getContactMethod(), 'validatedDate']); - const prevValidatedDate = lodashGet(prevProps.loginList, [this.getContactMethod(), 'validatedDate']); + const contactMethod = this.getContactMethod(); + const validatedDate = lodashGet(this.props.loginList, [contactMethod, 'validatedDate']); + const prevValidatedDate = lodashGet(prevProps.loginList, [contactMethod, 'validatedDate']); + const loginData = lodashGet(this.props.loginList, contactMethod, {}); + const isDefaultContactMethod = this.props.session.email === loginData.partnerUserID; // Navigate to methods page on successful magic code verification // validatedDate property is responsible to decide the status of the magic code verification if (!prevValidatedDate && validatedDate) { + // If the selected contactMethod is the current session['login'] and the account is unvalidated, + // the current authToken is invalid after the successful magic code verification. + // So we need to sign out the user and redirect to the sign in page. + if (isDefaultContactMethod) { + Session.signOutAndRedirectToSignIn(); + return; + } Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.route); } }