Skip to content

Commit

Permalink
Merge pull request Expensify#32897 from DylanDylann/fix/31856-user-is…
Browse files Browse the repository at this point in the history
…-signed-out-when-clicking-usd

Fix/31856: User is signed out
  • Loading branch information
thienlnam authored Dec 14, 2023
2 parents 17c1ea8 + 1953769 commit 83a89fb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 83a89fb

Please sign in to comment.