-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] Fix mobile transitions for some emails #9469
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
Merged
+54
−24
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a63dd86
Create isLogginInAsNewUser util function
neil-marcellini 61c5902
Use isLoggingInAsNewUser util
neil-marcellini 9a1e861
Fix isLogginInAsNewUser util with an early return
neil-marcellini 511af76
Update oldot encoding comment and remove link
neil-marcellini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import lodashGet from 'lodash/get'; | ||
|
|
||
| /** | ||
| * Determine if the transitioning user is logging in as a new user. | ||
| * | ||
| * @param {String} transitionURL | ||
| * @param {String} sessionEmail | ||
| * @returns {Boolean} | ||
| */ | ||
| function isLoggingInAsNewUser(transitionURL, sessionEmail) { | ||
| // The OldDot mobile app does not URL encode the parameters, but OldDot web | ||
| // does. We don't want to deploy OldDot mobile again, so as a work around we | ||
| // compare the session email to both the decoded and raw email from the transition link. | ||
| const params = new URLSearchParams(transitionURL); | ||
| const paramsEmail = params.get('email'); | ||
|
|
||
| // If the email param matches what is stored in the session then we are | ||
| // definitely not logging in as a new user | ||
| if (paramsEmail === sessionEmail) { | ||
| return false; | ||
| } | ||
|
|
||
| // If they do not match it might be due to encoding, so check the raw value | ||
| // Capture the un-encoded text in the email param | ||
| const emailParamRegex = /[?&]email=([^&]*)/g; | ||
| const matches = emailParamRegex.exec(transitionURL); | ||
| const linkedEmail = lodashGet(matches, 1, null); | ||
| return linkedEmail !== sessionEmail; | ||
| } | ||
|
|
||
| export { | ||
| // eslint-disable-next-line import/prefer-default-export | ||
|
neil-marcellini marked this conversation as resolved.
|
||
| isLoggingInAsNewUser, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you confirm this handles all four cases?
Specifically interested in case 2? e.g. when do we return true when
paramsEmail !== sessionEmail?Uh oh!
There was an error while loading. Please reload this page.
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.
Unencoded new user (OldApp new user)
The params and session emails don't match, then the linked and session emails also don't match so we correctly return
true.Encoded new user (OldDot new user)
The params and session emails don't match so we check the linked and session emails which
also don't match so we correctly return
true.Unencoded existing user (OldApp existing user)
The params and session emails don't match, but then the linked email matches the session email so we correctly return
false.Encoded existing user (OldDot existing user)
The params and session emails match so we correctly return
false.