Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix automatic authentication with magic link. #19637

Merged
merged 4 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -393,7 +393,7 @@ function signIn(password, validateCode, twoFactorAuthCode, preferredLocale = CON
API.write('SigninUser', params, {optimisticData, successData, failureData});
}

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 @@ -468,8 +468,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
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,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