Skip to content

Commit

Permalink
Merge pull request #19637 from Expensify/cristi_fix-signin-with-magic…
Browse files Browse the repository at this point in the history
…-link

Fix automatic authentication with magic link.
  • Loading branch information
NikkiWines authored May 31, 2023
2 parents ed9a6cc + fa8eb77 commit 79f3377
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/ValidateCode/ValidateCodeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const defaultProps = {
};

function ValidateCodeModal(props) {
const signInHere = useCallback(() => Session.signInWithValidateCode(props.accountID, props.code, null, props.preferredLocale), [props.accountID, props.code, props.preferredLocale]);
const signInHere = useCallback(() => Session.signInWithValidateCode(props.accountID, props.code, props.preferredLocale), [props.accountID, props.code, props.preferredLocale]);

return (
<View style={styles.deeplinkWrapperContainer}>
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function signIn(password, validateCode, twoFactorAuthCode, preferredLocale = CON
});
}

function signInWithValidateCode(accountID, code, twoFactorAuthCode, preferredLocale = CONST.LOCALES.DEFAULT) {
function signInWithValidateCode(accountID, code, preferredLocale = CONST.LOCALES.DEFAULT, twoFactorAuthCode = '') {
// If this is called from the 2fa step, get the validateCode directly from onyx
// instead of the one passed from the component state because the state is changing when this method is called.
const validateCode = twoFactorAuthCode ? credentials.validateCode : code;
Expand Down Expand Up @@ -495,8 +495,8 @@ function signInWithValidateCode(accountID, code, twoFactorAuthCode, preferredLoc
});
}

function signInWithValidateCodeAndNavigate(accountID, validateCode, twoFactorAuthCode, preferredLocale = CONST.LOCALES.DEFAULT) {
signInWithValidateCode(accountID, validateCode, twoFactorAuthCode, preferredLocale);
function signInWithValidateCodeAndNavigate(accountID, validateCode, preferredLocale = CONST.LOCALES.DEFAULT, twoFactorAuthCode = '') {
signInWithValidateCode(accountID, validateCode, preferredLocale, twoFactorAuthCode);
Navigation.navigate(ROUTES.HOME);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/ValidateLoginPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ValidateLoginPage extends Component {
// because we don't want to block the user with the interstitial page.
Navigation.goBack(false);
} else {
Session.signInWithValidateCodeAndNavigate(accountID, validateCode, null, this.props.preferredLocale);
Session.signInWithValidateCodeAndNavigate(accountID, validateCode, this.props.preferredLocale);
}
} else {
User.validateLogin(accountID, validateCode);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ValidateLoginPage/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ValidateLoginPage extends Component {
}

// The user has initiated the sign in process on the same browser, in another tab.
Session.signInWithValidateCode(this.getAccountID(), this.getValidateCode(), null, this.props.preferredLocale);
Session.signInWithValidateCode(this.getAccountID(), this.getValidateCode(), this.props.preferredLocale);
}

componentDidUpdate() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class BaseValidateCodeForm extends React.Component {

const accountID = lodashGet(this.props, 'credentials.accountID');
if (accountID) {
Session.signInWithValidateCode(accountID, this.state.validateCode, this.state.twoFactorAuthCode, this.props.preferredLocale);
Session.signInWithValidateCode(accountID, this.state.validateCode, this.props.preferredLocale, this.state.twoFactorAuthCode);
} else {
Session.signIn('', this.state.validateCode, this.state.twoFactorAuthCode, this.props.preferredLocale);
}
Expand Down

0 comments on commit 79f3377

Please sign in to comment.