-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow redirect to MagicLink after Invalid Validation Code #5150
Changes from 21 commits
b10f53f
0a6362e
a1ce081
0ecd7f7
3f1ad9e
745efbb
103bbc5
1e77d15
f278059
8e4f703
a1af035
f25e31f
418c8f6
f42b310
46cd66d
4b4f0ce
e486081
cf0fe90
587948f
0bfaf85
361f097
b1ba7fa
c51f126
c11c337
6180d9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -134,6 +134,7 @@ function fetchAccountDetails(login) { | |||||||||||||||||||||||||||||||||||
validated: response.validated, | ||||||||||||||||||||||||||||||||||||
closed: response.isClosed, | ||||||||||||||||||||||||||||||||||||
forgotPassword: false, | ||||||||||||||||||||||||||||||||||||
validateCodeExpired: false, | ||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
if (!response.accountExists) { | ||||||||||||||||||||||||||||||||||||
|
@@ -281,7 +282,7 @@ function resetPassword() { | |||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: true, forgotPassword: true}); | ||||||||||||||||||||||||||||||||||||
API.ResetPassword({email: credentials.login}) | ||||||||||||||||||||||||||||||||||||
.finally(() => { | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false}); | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false, validateCodeExpired: false}); | ||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
@@ -295,7 +296,7 @@ function resetPassword() { | |||||||||||||||||||||||||||||||||||
* @param {String} accountID | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
function setPassword(password, validateCode, accountID) { | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true}); | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true, validateCodeExpired: false}); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
API.SetPassword({ | ||||||||||||||||||||||||||||||||||||
password, | ||||||||||||||||||||||||||||||||||||
|
@@ -316,7 +317,16 @@ function setPassword(password, validateCode, accountID) { | |||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {error: Localize.translateLocal('setPasswordPage.accountNotValidated')}); | ||||||||||||||||||||||||||||||||||||
const login = lodashGet(response, 'data.email', null); | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, { | ||||||||||||||||||||||||||||||||||||
validated: true, accountExists: true, validateCodeExpired: true, error: Localize.translateLocal('setPasswordPage.accountNotValidated'), | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block gets called when validation code is expired and the account is validated. This flow comes from App/src/libs/actions/Session/index.js Line 413 in 01b7b60
Hence, I've updated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That explanation doesn't make sense to me. We are setting an error here that says: "We were unable to validate your account." And the account is being set as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I explained it right. Let me give it another short. In
Now the two instances of In short if I ask, if I remove the
Retain this:
Does the above change make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made the above change and tested it. It is working fine and guessing this should now cover all cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It makes sense as a quick solution. However, based on the full conversation in this PR so far - it isn't the one we want and will introduce inconsistency with how we handle errors. Please try to ask clarifying questions before proposing alternatives, because I'm not sure if we are seeing eye to eye on the problem. I will try to be as specific as possible so we can move on from this PR... The issue is with setting It seems the only reason we need to set this here is so that the correct error will show here: App/src/pages/signin/ResendValidationForm.js Lines 90 to 105 in 361f097
The |
||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
// This login is set with email received from the API so that the resend link can work if the user has hit a direct URL | ||||||||||||||||||||||||||||||||||||
marcaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
if (login) { | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.CREDENTIALS, {login}); | ||||||||||||||||||||||||||||||||||||
marcaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Navigation.navigate(ROUTES.HOME); | ||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||
.finally(() => { | ||||||||||||||||||||||||||||||||||||
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false}); | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of these names, especially when i read it in code like so,
Since its confusing to me why if showPasswordForm is true do we want welcomeBack versus welcome. Plus variables should be named after their intention of like what they store and not their parent/class names.
So in this case
welcome
, wants the phone or email so i would suggest -enterPhoneOrEmail
. This becomes welcomeText.enterPhoneOrEmail which is a lot cleaner as welcomeText.welcome is redundant.As for
welcomeBack
, it wants the password so i would suggest -enterPassword
.So now the logic becomes,
which is a lot more verbose and cleaner imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a NAB - not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. In general, feels like the names for these translation keys is a bit all over the place. Wondering if we can maybe come up with some standard guidance for how to name them and then get everyone to apply it in a consistent way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, love it.