Skip to content

fix: skip redirect from login modal#4450

Open
jason10lee wants to merge 3 commits intotrunkfrom
fix/modal-skip-login-redirect
Open

fix: skip redirect from login modal#4450
jason10lee wants to merge 3 commits intotrunkfrom
fix/modal-skip-login-redirect

Conversation

@jason10lee
Copy link
Contributor

@jason10lee jason10lee commented Feb 3, 2026

All Submissions:

Changes proposed in this Pull Request:

Login flow for existing users from Reader Registration block happens in a modal. And end of successful login, reader has the option to either hit the 'Continue' button or the 'X' to exit the flow. 'Continue' redirects to a signup page; 'X' closes the modal and leaves the user on the page they started the flow.

This PR detects whether the form is being shown in a modal; if so, it skips the redirect step so that 'Continue' will close the modal just like the 'X' button.

Note that the block may appear on a standalone page (like /my-account/ when not logged in). In those cases, the existing behavior--the redirect--is left unchanged so that the reader exits at a useful location.

Addresses NPPM-2542: Bug: Reader Registration block redirects off the current page after using the Magic Link OTP.

How to test the changes in this Pull Request:

Original modal flow as documented in the Linear issue

  1. Pull fix/modal-skip-login-redirect topic branch.
  2. Add the Reader Registration block to any page, such as the Home Page
  3. Create a reader account on the site (if one doesn't exist).
  4. Either log out or open a fresh browser session.
  5. Navigate to the Reader Registration block and select "Sign into an existing account".
  6. Enter the email address of the existing reader account and select "Continue".
  7. Enter the OTP and hit continue.
  8. On the success page, select 'Continue'. Verify it closes the modal and leaves you where you started.

Standalone page test

  1. As 1-3 above; make sure you're logged out before proceeding.
  2. Navigate to a page that will show a standalone login form, like /my-account/.
  3. Complete the login flow.
  4. On success, select 'Continue'. Verify it redirects you off the login page.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the Reader Registration “sign into an existing account” flow so that when it’s initiated from within an overlay/modal context, the post-login “Continue” action doesn’t redirect away from the underlying page.

Changes:

  • Detect whether the account-link trigger lives inside an overlay/modal container via closest(...).
  • Skip configuring the redirect callback when inside an overlay, so “Continue” closes the modal instead of navigating away.
Comments suppressed due to low confidence (1)

src/reader-activation-auth/index.js:79

  • isInsideOverlay currently disables the redirect callback entirely. Since openAuthModal() uses onSuccess as a fallback when the reader is already authenticated or when the auth modal container is missing, this makes the click a no-op in overlay contexts (the handler still calls preventDefault()). Consider always setting a callback when redirect is present, and inside that callback only skipping the redirect when it’s invoked from a successful auth flow (i.e., when it receives the (message, data) args from authCallback), while still redirecting on the no-args fallback path.
			if ( redirect && redirect !== '#' && ! isInsideOverlay ) {
				callback = () => {
					window.location.href = redirect;
				};
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jason10lee and others added 2 commits February 2, 2026 21:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jason10lee jason10lee marked this pull request as ready for review February 3, 2026 16:52
@jason10lee jason10lee requested a review from a team as a code owner February 3, 2026 16:52
@jason10lee jason10lee added the [Status] Needs Review The issue or pull request needs to be reviewed label Feb 3, 2026
@jason10lee
Copy link
Contributor Author

The PR as is should meet the question as asked.

However, I noticed that either 'X'-ing out or hitting 'Continue' without redirecting leaves links to 'My Account' (in the success state of the Reader Registration block or other existing login links) in a bit of a broken state. It redirects to /my-account/ which then leaves the user at a sign-in prompt instead of moving them along to the /my-account/edit-account/ page they'd usually see when logged in.

I suspect other things that check for login will also be broken until the page is refreshed.

On that note, maybe an alternative might be to redirect to the current page to refresh the login state rather than dropping the redirect altogether? This'd probably need to be added to the 'X', too.
Screenshot 2026-02-03 at 09 08 42
Screenshot 2026-02-03 at 09 09 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant