Login: Fix magic login redirect loop for passwordless accounts#108992
Draft
Login: Fix magic login redirect loop for passwordless accounts#108992
Conversation
Jetpack Cloud Live (direct link)
Automattic for Agencies Live (direct link)
Dashboard Live (dotcom) (direct link)
|
Contributor
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
After a successful login, if the sanitized redirect URL points back to /log-in, redirect to / instead. A successful login should never send the user back to the login page, and doing so creates an infinite loop for passwordless accounts. Co-Authored-By: Claude Opus 4.6 <[email protected]>
2f76553 to
b438b34
Compare
Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of DOTOBRD-359, CMM-1230
Proposed Changes
rebootAfterLogin, detect when the sanitized redirect URL points back to/log-inand unwrap the innerredirect_toparameter, redirecting to the actual destination directly.redirectLoggedIn, extend theisExternalUrlcheck to allow*.wordpress.comsubdomains (e.g.,mysite.wordpress.com) so WoW site URLs are not rejected as external.Why are these changes being made?
When a passwordless user clicks their magic login link, the
wp-login.php?action=magic-loginAPI authenticates them successfully but returns a sanitizedredirect_toURL that wraps the actual destination in a login page URL:rebootAfterLoginthen redirects to this login page URL. Since the user is passwordless, they cannot complete login at/log-in/, creating an infinite loop. This blocks all passwordless account login and new account creation (which defaults to passwordless).Additionally, when a logged-in user lands on
/log-in/?redirect_to=https://mysite.wordpress.com/..., theredirectLoggedInmiddleware rejects the subdomain URL as "external" and falls back to redirecting to/instead of the user's site.This was confirmed and the approach suggested by mmtr on DOTOBRD-359.
Testing Instructions
yarn test-client client/state/login/actions/test/reboot-after-login.jsyarn test-client client/login/test/redirect-to-login.jsPre-merge Checklist
🤖 Generated with Claude Code