Skip to content

feat(reader-registration-block): password, OTP, and verification flows#4452

Merged
miguelpeixe merged 31 commits into
trunkfrom
feat/reader-registration-block-auth
Feb 20, 2026
Merged

feat(reader-registration-block): password, OTP, and verification flows#4452
miguelpeixe merged 31 commits into
trunkfrom
feat/reader-registration-block-auth

Conversation

@miguelpeixe
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe commented Feb 4, 2026

All Submissions:

Changes proposed in this Pull Request:

NPPD-1142

Refactors the Reader Registration block to support unified authentication and account verification flows.

image

The block will no longer provide 2 actions (sign up or sign in), but rather a single "Continue" button that can register the account or open the auth modal to continue authenticating from there.

If the account is being registered and the block is being used in a gated article that requires verification, the block will present an account verification flow.

Modal after entering email:

image

Page render if already logged in with an unverified account:

image

How to test the changes in this Pull Request:

  1. Setup a content gate with registration access that doesn't require verification
  2. Edit the layout and add a reader registration block
  3. In a fresh session, visit a gated article and enter new email
  4. Confirm the block renders a success message, refreshes and unlocks the content
  5. Edit the gate to require account verification
  6. Refresh the article page while logged in with the newly created reader account
  7. Confirm you are gated again requiring verification
  8. Click Send code and confirm the OTP modal opens
  9. Enter the code and confirm that the page refreshes on success and the content is unlocked
  10. In a fresh session, enter a new email and confirm the verification step renders in a modal
  11. Click "Send code" and confirm you are able to go through

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
Copy Markdown
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

This PR refactors the Reader Registration block to support a complete authentication flow, including password and OTP authentication for existing users. The changes extract reusable authentication utilities, add new UI states for OTP and password entry, and modify the block to handle returning users differently from new registrations.

Changes:

  • Refactored OTP input handling into reusable, exportable functions in otp-input.js
  • Created shared authentication utilities in auth-utils.js for OTP, password, and magic link handling
  • Added OTP and password authentication UI states to the Reader Registration block
  • Updated backend to detect whether existing users need password or OTP authentication

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/reader-activation-auth/otp-input.js Refactored OTP input initialization into exportable functions for reusability
src/reader-activation-auth/auth-utils.js New file containing shared authentication utilities (OTP, password, magic link handlers)
src/reader-activation-auth/auth-form.js Updated to use shared authentication utilities from auth-utils.js
src/blocks/reader-registration/view.js Implemented authentication flows with OTP and password states; fixed spelling errors
src/blocks/reader-registration/index.php Added logic to determine authentication method for existing users; removed sign-in link
src/blocks/reader-registration/style.scss Added styles for OTP and password authentication UI states
src/blocks/reader-registration/edit.js Removed sign-in link UI from block editor
src/blocks/reader-registration/block.json Removed signInLabel attribute; updated signedInLabel default

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

Comment thread src/reader-activation-auth/auth-utils.js Outdated
Comment thread src/reader-activation-auth/auth-utils.js Outdated
Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/reader-activation-auth/auth-utils.js Outdated
Comment thread src/blocks/reader-registration/view.js Outdated
@miguelpeixe miguelpeixe changed the title feat(reader-registration-block): password and OTP authentication flows feat(reader-registration-block): password, OTP, and verification flows Feb 5, 2026
@miguelpeixe miguelpeixe requested a review from Copilot February 5, 2026 22:17
Copy link
Copy Markdown
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.


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

Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/reader-activation-auth/otp-input.js
Comment thread src/blocks/reader-registration/index.php
Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/blocks/reader-registration/index.php Outdated
Comment thread src/blocks/reader-registration/view.js Outdated
Comment thread src/reader-activation-auth/auth-form.js Outdated
@thomasguillot
Copy link
Copy Markdown
Contributor

@miguelpeixe Obrigado!

Copy link
Copy Markdown
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

This looks great and works well! A couple of questions which may or not be blocking:

  1. If you encounter the gate with a Registration block and enter an email address for an account for which you've previously verified by setting a password, you're correctly presented with the password prompt. The only thing that's weird with this is the "Go back" button. Clicking this returns to the first screen of the sign in modal, which feels like part of a different flow. In this scenario, I feel we should either hide the "Go back" button, or alter its behavior so that it simply closes the modal.
Image
  1. This probably wouldn't be a problem for new setups, but lots of sites have links with #register_modal to open the auth modal in their content gates. If you encounter the Registration gate after registering but before verifying, you can still see these links but they won't do anything. We're already hiding #signin_modal links with some CSS—can we also hide #register_modal links? Probably just need to add a selector like so:
body.logged-in a[href="#signin_modal"],
body.logged-in a[href="#register_modal"] {

An even better solution for this might be to allow the #register_modal links to open the same OTP verification modal as the Registration block if you're logged into an unverified account, but that might be more effort than it's worth.

@github-actions github-actions Bot added the [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator label Feb 17, 2026
@dkoo dkoo removed the [Status] Needs Review The issue or pull request needs to be reviewed label Feb 18, 2026
@miguelpeixe
Copy link
Copy Markdown
Member Author

Thank you for the review, @dkoo!

Clicking this returns to the first screen of the sign in modal, which feels like part of a different flow. In this scenario, I feel we should either hide the "Go back" button, or alter its behavior so that it simply closes the modal.

Good point. I removed the "Go back" button when in the verification state, because that would mean to enter an email while authenticated, which makes no sense. I didn't think to do that while authenticating because it's technically fine. Before I make the change, could you share your thoughts @thomasguillot?

If you encounter the Registration gate after registering but before verifying, you can still see these links but they won't do anything.

I think the ideal solution is to use a block compatible with account verification if the publisher enables that requirement. Even if we add support to the #register_modal to open the verification modal, there needs to be appropriate messaging. The reader won't click the "Register" button while logged in, expecting to run an account verification flow. Perhaps another block, similar to the My Account block that @laurelfulford built?

@thomasguillot
Copy link
Copy Markdown
Contributor

If we're removing the "Go back" button (which I'm fine with), can we make the second Secondary button, a ghost button (Forget password)

@dkoo
Copy link
Copy Markdown
Contributor

dkoo commented Feb 19, 2026

I think the ideal solution is to use a block compatible with account verification if the publisher enables that requirement. Even if we add support to the #register_modal to open the verification modal, there needs to be appropriate messaging. The reader won't click the "Register" button while logged in, expecting to run an account verification flow. Perhaps another block, similar to the My Account block that @laurelfulford built?

Good points, but in the meantime I think we should still at least hide these links for logged-in readers so there's no non-functional UI.

@miguelpeixe
Copy link
Copy Markdown
Member Author

Thanks, both!

For consistency, in 141a7cc I'm opting to keep the "Go back" button and allow it to close the modal. I changed the verification modal as well, so it also preserves the button. Just like clicking the X, it'll also force a page refresh so it ensures the block renders the verification box after registration. WDYT?

Good points, but in the meantime I think we should still at least hide these links for logged-in readers so there's no non-functional UI.

Updated in 9644618

Copy link
Copy Markdown
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

This works for me! One thing I did notice is that typing an email into the Registration block then hitting the "enter" key seems to submit the form and bypass the JS handler—might want to double check that since it's an accessibility issue, but I don't think that's new to this PR.

@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator labels Feb 19, 2026
@miguelpeixe
Copy link
Copy Markdown
Member Author

Thanks, @dkoo! I'll look into the input "enter" key issue

@miguelpeixe miguelpeixe merged commit fc4567e into trunk Feb 20, 2026
9 checks passed
@miguelpeixe miguelpeixe deleted the feat/reader-registration-block-auth branch February 20, 2026 12:26
@github-actions
Copy link
Copy Markdown

Hey @miguelpeixe, 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 Mar 5, 2026
# [6.35.0-alpha.1](v6.34.2...v6.35.0-alpha.1) (2026-03-05)

### Bug Fixes

* allow deletion of payment method for Braintree ([63ceec3](63ceec3))
* apply Copilot suggestion for tests ([6133636](6133636))
* **avatar:** correct duotone selector to support custom colors ([#4513](#4513)) ([c4458d4](c4458d4))
* **byline:** update placeholder text to "Author Name" ([#4510](#4510)) ([727b1e8](727b1e8))
* **co-authors-plus:** sanitize user_login before building dummy email… ([#4520](#4520)) ([32c2602](32c2602))
* do not depend on _get() to return an array ([2816470](2816470))
* **dropdown-menu:** avoid overflow at bottom of viewport ([#4495](#4495)) ([a5ce464](a5ce464))
* enable payment method deletion for Braintree ([c50f094](c50f094))
* iframe editor compatiblity ([#4444](#4444)) ([12dfaba](12dfaba))
* **my-account:** don't show subscription payment notice in modal checkout ([#4500](#4500)) ([2cb3324](2cb3324))
* **my-account:** force white background color ([#4514](#4514)) ([02e2555](02e2555))
* **my-account:** resubscription validation in order-again template ([#4498](#4498)) ([36871fc](36871fc))
* **newspack-icon:** background color ([#4516](#4516)) ([8c5dc9c](8c5dc9c))
* **newspack-ui:** remove overflow when modal is open ([#4515](#4515)) ([0b2cbd3](0b2cbd3))
* prune read-only keys from sync queue ([bf81734](bf81734))
* remove unused 'edit' and 'save' actions from Braintree payment methods ([8f72a8d](8f72a8d))
* **snackbar:** autohide progress bar not always appearing ([#4504](#4504)) ([4eda60f](4eda60f))

### Features

*  identify and enforce read-only items for Reader Data Library ([4f2ef8a](4f2ef8a))
* add featured image caption block ([#4519](#4519)) ([0b744ff](0b744ff))
* **author-profile:** avatar and social blocks for nested author profile ([#4448](#4448)) ([cff670b](cff670b))
* **content-gate:** comment restriction with metering support ([#4529](#4529)) ([714c8b7](714c8b7))
* **content-gate:** per-post access control exemption ([#4530](#4530)) ([636679b](636679b))
* **content-gate:** user access information ([#4542](#4542)) ([b49347e](b49347e))
* **content-gating:** group subscription invitations data structure + admin UI ([#4536](#4536)) ([e609e83](e609e83))
* **content-gating:** i3 designs for content gates list view ([#4512](#4512)) ([dcbb239](dcbb239))
* **corrections:** append corrections to Republication Tracker Tool content ([#4501](#4501)) ([71bd177](71bd177))
* data event handler registration and dispatching to integrations ([#4481](#4481)) ([7c79da6](7c79da6))
* **data-events:** add ActionScheduler logging and retry reason ([#4488](#4488)) ([e8af964](e8af964))
* **integrations:** make sure contact data is read from persistent data ([#4505](#4505)) ([c2ee26a](c2ee26a))
* **integrations:** start get fields abstraction and pull contact data ([#4470](#4470)) ([8ddcf23](8ddcf23)), closes [#4477](#4477)
* **reader-registration-block:** password, OTP, and verification flows ([#4452](#4452)) ([fc4567e](fc4567e))
* reject changes to specific reader data keys ([fe52e12](fe52e12))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 16, 2026
# [6.35.0](v6.34.4...v6.35.0) (2026-03-16)

### Bug Fixes

* allow deletion of payment method for Braintree ([63ceec3](63ceec3))
* apply Copilot suggestion for tests ([6133636](6133636))
* **avatar:** correct duotone selector to support custom colors ([#4513](#4513)) ([c4458d4](c4458d4))
* **byline:** update placeholder text to "Author Name" ([#4510](#4510)) ([727b1e8](727b1e8))
* **co-authors-plus:** sanitize user_login before building dummy email… ([#4520](#4520)) ([32c2602](32c2602))
* do not depend on _get() to return an array ([2816470](2816470))
* **dropdown-menu:** avoid overflow at bottom of viewport ([#4495](#4495)) ([a5ce464](a5ce464))
* enable payment method deletion for Braintree ([c50f094](c50f094))
* iframe editor compatiblity ([#4444](#4444)) ([12dfaba](12dfaba))
* **my-account:** don't show subscription payment notice in modal checkout ([#4500](#4500)) ([2cb3324](2cb3324))
* **my-account:** force white background color ([#4514](#4514)) ([02e2555](02e2555))
* **my-account:** resubscription validation in order-again template ([#4498](#4498)) ([36871fc](36871fc))
* **newspack-icon:** background color ([#4516](#4516)) ([8c5dc9c](8c5dc9c))
* **newspack-ui:** remove overflow when modal is open ([#4515](#4515)) ([0b2cbd3](0b2cbd3))
* prune read-only keys from sync queue ([bf81734](bf81734))
* remove unused 'edit' and 'save' actions from Braintree payment methods ([8f72a8d](8f72a8d))
* **snackbar:** autohide progress bar not always appearing ([#4504](#4504)) ([4eda60f](4eda60f))

### Features

*  identify and enforce read-only items for Reader Data Library ([4f2ef8a](4f2ef8a))
* add featured image caption block ([#4519](#4519)) ([0b744ff](0b744ff))
* **author-profile:** avatar and social blocks for nested author profile ([#4448](#4448)) ([cff670b](cff670b))
* **content-gate:** comment restriction with metering support ([#4529](#4529)) ([714c8b7](714c8b7))
* **content-gate:** per-post access control exemption ([#4530](#4530)) ([636679b](636679b))
* **content-gate:** user access information ([#4542](#4542)) ([b49347e](b49347e))
* **content-gating:** group subscription invitations data structure + admin UI ([#4536](#4536)) ([e609e83](e609e83))
* **content-gating:** i3 designs for content gates list view ([#4512](#4512)) ([dcbb239](dcbb239))
* **corrections:** append corrections to Republication Tracker Tool content ([#4501](#4501)) ([71bd177](71bd177))
* data event handler registration and dispatching to integrations ([#4481](#4481)) ([7c79da6](7c79da6))
* **data-events:** add ActionScheduler logging and retry reason ([#4488](#4488)) ([e8af964](e8af964))
* **integrations:** make sure contact data is read from persistent data ([#4505](#4505)) ([c2ee26a](c2ee26a))
* **integrations:** start get fields abstraction and pull contact data ([#4470](#4470)) ([8ddcf23](8ddcf23)), closes [#4477](#4477)
* **reader-registration-block:** password, OTP, and verification flows ([#4452](#4452)) ([fc4567e](fc4567e))
* reject changes to specific reader data keys ([fe52e12](fe52e12))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.35.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

[Status] Approved The pull request has been reviewed and is ready to merge [Status] Design Approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants