-
Notifications
You must be signed in to change notification settings - Fork 295
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
Enhance wording of "Invalid nonce" messaging #3098
Comments
@felixarntz assigning to you to determine the specific wording to be used. |
@aaemnnosttv Can you clarify what the intention of the improved messaging here is? I'm not sure I understand your point in the linked comment. I agree it makes sense to come up with more helpful messages here, but realistically what is the solution in those scenarios? WordPress in some places is telling the user to refresh and try again, but I doubt that would help here. In other places it's also just saying something that the nonce is invalid. Maybe just use core's |
@felixarntz the general intention is to offer a better experience as it's currently a rather uninformative dead-end. I think We could also build our own similar function which has its own cases for specific actions like I would be happy to proceed with it as-is unless you (or maybe @eugene-manuilov) have any other ideas? |
Yeah, let's go with |
@felixarntz @aaemnnosttv unfortunately, I think I think we need to create our own version of the |
Good point @eugene-manuilov, I've updated the ACs to cater differently for invalid nonces for actions related to the proxy. |
Can you clarify what situations you mean here? Is there anything specific you need covered in the IB? |
@johnPhillips Yes – the new method is described to be based on |
Got it, thanks @aaemnnosttv |
@johnPhillips would it be possible to add an estimate here now the IB is completed please? |
IB ✅ |
@johnPhillips if we make the method private, we can't call it from |
@ivankruchkoff Good question. I will have added that detail because it was specific in the AC, so perhaps it's a good idea to ask @aaemnnosttv for some clarity? |
@ivankruchkoff could you please add QAB? |
QA ✅ Added calls to |
Feature Description
There are a few cases in the plugin where we currently
wp_die
with "Invalid nonce". This is not the most useful message for a case that is likely uncommon but still fairly possible for a user to encounter. As such, we should re-evaluate the messaging used in each case and potentially add a retry mechanism for better UX such as that discussed in #2935 (comment).Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Authentication::invalid_nonce_error( $action )
should be introduced:wp_nonce_ays
function of WordPress core, in fact itselse
case can be used as is for the "default" case, so the new method should probably actually callwp_nonce_ays
in certain situations.log-out
condition thatwp_nonce_ays
has, we should have special behavior for proxy-related invalid nonces: If the nonce$action
starts withgooglesitekit_proxy_
, instead of using the referer like WordPress core does by default, our "link back" URL should be thegooglesitekit-splash
screen. The messaging should remain the same as in WordPress core.Implementation Brief
Add new invalid nonce error method
Add a new private method,
Authentication::invalid_nonce_error( $action )
.$action
parameter here will be a string describing the nonce action.$action
in order to deal with certain edge cases, but will fall through to thewp_nonce_ays
function in WP core as the default behavior if none apply.Here we need to add a check to determine whether the invalid nonce is proxy-related.
$action
parameter starts with the substringgooglesitekit_proxy_
.wp_nonce_ays
, i.e.'The link you followed has expired. Please try again'
(the linked text being 'Please try again').googlesitekit-splash
screen instead.$action
is not proxy-related, fall through to callingwp_nonce_ays
as the default behavior.Add test coverage for this new method.
Refactor instances of
wp_die
to use the new methodRefactor all instances where Site Kit currently dies with an "Invalid nonce." error message to instead rely on the new
Authentication::invalid_nonce_error
method, for example:includes/Core/Authentication/Authentication.php:
includes/Core/Util/Reset.php:
You will likely need to refactor the test coverage for these files as well to reflect the changes.
Test Coverage
Visual Regression Changes
QA Brief
wp-admin/admin.php?page=googlesitekit-splash
Changelog entry
The text was updated successfully, but these errors were encountered: