-
Notifications
You must be signed in to change notification settings - Fork 59
feat: lock access to My Account UI until account is verified #1877
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
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eb60809
refactor: move email verification methods to main plugin
dkoo f7fb114
Revert "refactor: move email verification methods to main plugin"
dkoo 4d105f3
feat: use magic link email instead of Newsletters verification email …
dkoo fae8ff3
refactor: move all reader verification logic to Reader_Activation class
dkoo c8aa796
refactor: authenticate reader as a primary function of authenticate m…
dkoo 5bfa886
feat: block access to My Account pages until reader account is verified
dkoo 20a53ea
fix: do not lock access if Reader_Activation is not enabled
dkoo 7cd9b09
chore: restore missing doc line
dkoo 7843192
fix: avoid redirecting non-account pages
dkoo 789d6d3
fix: redirect to edit-account if unverified and a non-root account page
dkoo 723a5cd
refactor: use add_query_arg to build verification URLs
dkoo 81b8c5c
fix: sanitize the message
dkoo bc2d507
fix: sanitize the error
dkoo 44e3abf
fix: use boolval to sanitize boolean $is_error value
dkoo 975c28d
fix: avoid globals and fix verification redirect URLs
dkoo d6f8e41
fix: update method name for clarity
dkoo 457d69d
fix: consider non-RAS reader users to be verified
dkoo 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
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
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,66 @@ | ||
| <?php | ||
| /** | ||
| * My Account page before account has been verified. | ||
| * The user will be asked to verify before they can manage account settings. | ||
| * | ||
| * @package Newspack | ||
| */ | ||
|
|
||
| use \Newspack\WooCommerce_My_Account; | ||
|
|
||
| defined( 'ABSPATH' ) || exit; | ||
|
|
||
| \do_action( 'woocommerce_before_edit_account_form' ); | ||
|
|
||
| $newspack_reset_password_arg = WooCommerce_My_Account::RESET_PASSWORD_URL_PARAM; | ||
| $newspack_send_magic_link_arg = WooCommerce_My_Account::SEND_MAGIC_LINK_PARAM; | ||
|
|
||
| $message = false; | ||
| if ( isset( $_GET['message'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
| $message = sanitize_text_field( $_GET['message'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
| } | ||
|
|
||
| $is_error = false; | ||
| if ( isset( $_GET['is_error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
| $is_error = boolval( $_GET['is_error'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
| } | ||
| ?> | ||
|
|
||
| <?php | ||
| if ( $message ) : | ||
| ?> | ||
| <div class="newspack-wc-message <?php echo $is_error ? 'newspack-wc-message--error' : ''; ?>"> | ||
| <p><?php echo \esc_html( $message ); ?></p> | ||
| </div> | ||
| <?php | ||
| endif; | ||
|
|
||
| $magic_link_args = []; | ||
| $magic_link_args[ $newspack_send_magic_link_arg ] = wp_create_nonce( $newspack_send_magic_link_arg ); | ||
| $magic_link_url = \add_query_arg( | ||
| $magic_link_args, | ||
| \wc_get_account_endpoint_url( 'edit-account' ) | ||
| ); | ||
| $reset_password_args = []; | ||
| $reset_password_args[ $newspack_reset_password_arg ] = wp_create_nonce( $newspack_reset_password_arg ); | ||
| $reset_password_url = \add_query_arg( | ||
| $reset_password_args, | ||
| \wc_get_account_endpoint_url( 'edit-account' ) | ||
| ); | ||
| ?> | ||
|
|
||
| <div class="newspack-verify-account-message"> | ||
| <p> | ||
| <?php esc_html_e( 'You must verify your account before you can manage account settings. Verify with a link or by setting a password.', 'newspack' ); ?> | ||
| </p> | ||
| <p> | ||
| <a class="woocommerce-Button button" href="<?php echo esc_url( $magic_link_url ); ?>"> | ||
| <?php esc_html_e( 'Send me a link', 'newspack' ); ?> | ||
| </a> | ||
| <a class="woocommerce-Button button" href="<?php echo esc_url( $reset_password_url ); ?>"> | ||
| <?php esc_html_e( 'Set a new password', 'newspack' ); ?> | ||
| </a> | ||
| </p> | ||
| </div> | ||
|
|
||
| <?php \do_action( 'woocommerce_after_edit_account_form' ); ?> |
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.
Uh oh!
There was an error while loading. Please reload this page.