Skip to content

Conversation

@rbcorrales
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

When users authenticate via OAuth flows, the authentication form now passes the full redirect URL to the backend, enabling backend email sending code to detect OAuth contexts.

This PR also adds a new newspack_magic_link_email_config filter that allows external plugins to override which email template is used for OTP/magic link emails based on the authentication context, and makes the is_oauth_redirect() method public so it can be reused externally.

Closes NPPD-1008 (please check the ticket for additional context and dependencies).

How to test the changes in this Pull Request:

  1. Enable the "Use My Account login screen for OAuth clients" toggle in Audience Management > Configuration.
  2. Navigate to an OAuth authorization URL: https://your-site.com/oauth/authorize/?prompt=login&scope=openid+offline_access&code_challenge_method=S256&response_type=code&client_id=<YOUR_CLIENT_ID>&redirect_uri=https%3A%2F%2Fexample.com%2F&code_challenge=<SAMPLE_CHALLENGE>
  3. You should be redirected to /my-account/?redirect=<encoded_oauth_url>.
  4. Enter an email address and click "Continue" or request an OTP code.
    • Note: When the user doesn't have a password set, the email is requested as soon as they click "Continue". Otherwise, the next screen presents the option to use the password and a button to request an OTP. This flow hasn't changed, but testing both scenarios is recommended.
  5. Open browser DevTools > Network tab and inspect the POST request to /my-account/.
  6. Verify that the form data includes a redirect_url field containing the full URL with the redirect query parameter (e.g., https://your-site.com/my-account/?redirect=...).
  7. Test a normal login flow on /my-account/ (without the OAuth or redirect params) and verify it still works as expected.

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?

@rbcorrales rbcorrales requested a review from a team as a code owner December 4, 2025 06:55
@rbcorrales rbcorrales changed the title Feat/ras oauth otp flow feat: RAS OAuth OTP flow improvements Dec 4, 2025
@rbcorrales rbcorrales requested a review from Copilot December 4, 2025 07:10
Copy link

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

This PR enhances the OAuth OTP flow by enabling the authentication form to pass the full redirect URL to the backend. This allows backend email code to detect OAuth contexts and customize email templates accordingly.

Key changes include:

  • Added a newspack_magic_link_email_config filter for customizing email templates based on authentication context
  • Made the is_oauth_redirect() method public for external reuse
  • Updated frontend authentication logic to capture and send the full redirect URL when a redirect query parameter is present

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
includes/class-magic-link.php Adds the newspack_magic_link_email_config filter to allow customization of email templates based on authentication context
includes/reader-activation/class-reader-activation.php Changes is_oauth_redirect() method visibility from private to public for external reuse
src/reader-activation-auth/auth-form.js Updates authentication form submission logic to include full redirect URL when redirect query parameter is present
tests/unit-tests/magic-link.php Adds test coverage for the new newspack_magic_link_email_config filter
tests/unit-tests/reader-activation.php Adds tests for is_oauth_redirect() method and its extensibility via filter

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

@rbcorrales rbcorrales added the [Status] Needs Review The issue or pull request needs to be reviewed label Dec 4, 2025
@rbcorrales rbcorrales changed the title feat: RAS OAuth OTP flow improvements feat(ras): OAuth OTP flow improvements Dec 4, 2025
Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

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

Works as described!

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Dec 8, 2025
@leogermani leogermani merged commit 8b345fa into trunk Dec 8, 2025
11 checks passed
@leogermani leogermani deleted the feat/ras-oauth-otp-flow branch December 8, 2025 21:29
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Hey @rbcorrales, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Dec 11, 2025
# [6.28.0-alpha.1](v6.27.1...v6.28.0-alpha.1) (2025-12-11)

### Bug Fixes

* **content-gating:** never gate special pages ([#4340](#4340)) ([a4dcfdd](a4dcfdd))
* **countdown-banner:** don't show on unrestricted posts ([#4349](#4349)) ([66d2c94](66d2c94))
* **indesign-export:** only register the attribute for allowed blocks ([#4330](#4330)) ([e1801cb](e1801cb))
* **my-account:** safe content argument to skip sanitization ([#4326](#4326)) ([b066de5](b066de5))
* **my-account:** set new payment method as default ([#4343](#4343)) ([6ebcaf9](6ebcaf9))
* **my-account:** support dynamic content around shortcode ([#4328](#4328)) ([36b9524](36b9524))
* **subscription-tiers-modal:** skip private products ([#4337](#4337)) ([564d803](564d803))

### Features

* **content-gate:** content rules ([#4265](#4265)) ([b5b8cd9](b5b8cd9))
* **content-gate:** implement restriction rules ([#4251](#4251)) ([4034103](4034103))
* metered content countdown banner ([#4315](#4315)) ([c9a68cc](c9a68cc))
* **payment-notice:** detect equivalent subscription ([#4333](#4333)) ([9a98889](9a98889))
* **ras:** OAuth OTP flow improvements ([#4341](#4341)) ([8b345fa](8b345fa))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.28.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jan 5, 2026
# [6.28.0](v6.27.4...v6.28.0) (2026-01-05)

### Bug Fixes

* **content-gating:** never gate special pages ([#4340](#4340)) ([a4dcfdd](a4dcfdd))
* **countdown-banner:** don't show on unrestricted posts ([#4349](#4349)) ([66d2c94](66d2c94))
* **countdown-banner:** never show more views than total ([#4369](#4369)) ([0ef3a24](0ef3a24))
* **indesign-export:** only register the attribute for allowed blocks ([#4330](#4330)) ([e1801cb](e1801cb))
* **my-account:** safe content argument to skip sanitization ([#4326](#4326)) ([b066de5](b066de5))
* **my-account:** set new payment method as default ([#4343](#4343)) ([6ebcaf9](6ebcaf9))
* **my-account:** support dynamic content around shortcode ([#4328](#4328)) ([36b9524](36b9524))
* **subscription-tiers-modal:** skip private products ([#4337](#4337)) ([564d803](564d803))

### Features

* **content-gate:** content rules ([#4265](#4265)) ([b5b8cd9](b5b8cd9))
* **content-gate:** implement restriction rules ([#4251](#4251)) ([4034103](4034103))
* metered content countdown banner ([#4315](#4315)) ([c9a68cc](c9a68cc))
* **payment-notice:** detect equivalent subscription ([#4333](#4333)) ([9a98889](9a98889))
* **ras:** OAuth OTP flow improvements ([#4341](#4341)) ([8b345fa](8b345fa))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.28.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants