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
Changes from 2 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
23 changes: 12 additions & 11 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,18 @@ function signInWithValidateCode(accountID, code, twoFactorAuthCode, preferredLoc
},
];

API.write(
'SigninUserWithLink',
{
accountID,
validateCode,
twoFactorAuthCode,
preferredLocale,
deviceInfo: getDeviceInfoForLogin(),
},
{optimisticData, successData, failureData},
);
const params = {
accountID,
validateCode,
preferredLocale,
deviceInfo: getDeviceInfoForLogin(),
};

// Pass twoFactorAuthCode to sever only if it has a valid value, otherwise php might convert it to "null" as a string.
cristipaval marked this conversation as resolved.
Show resolved Hide resolved
if (twoFactorAuthCode) {
params.twoFactorAuthCode = twoFactorAuthCode;
}
Copy link
Contributor

@NikkiWines NikkiWines May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're explicitly passing null for the twoFactorAuthCode in several places (but that we often pass a preferredLocale, which is the param after it).

Maybe a cleaner solution would be to update this function (and also signInWithValidateCodeAndNavigate which calls this) so that twoFactorAuthCode is the last param and defaults to ''. Then we don't even need this if

It's more changes but ultimately I think it's better than passing null in a bunch of places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristipaval Are you going to make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on them atm

API.write('SigninUserWithLink', params, {optimisticData, successData, failureData});
}

function signInWithValidateCodeAndNavigate(accountID, validateCode, twoFactorAuthCode, preferredLocale = CONST.LOCALES.DEFAULT) {
Expand Down