Skip to content
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

[Feature]: Throw custom exception for invalid nonces #159

Closed
1 task done
calvinalkan opened this issue Oct 21, 2022 · 1 comment
Closed
1 task done

[Feature]: Throw custom exception for invalid nonces #159

calvinalkan opened this issue Oct 21, 2022 · 1 comment
Assignees
Labels
feature New feature or request released

Comments

@calvinalkan
Copy link
Member

Thanks for taking the time to fill out this feature request!"

  • I have searched the issue tracker for similar requests

Which @snicco/* package(s) are relevant/related of the feature request?

wp-nonce-middleware

Description

It would be good to replace the generic HttpException thrown in the VerifyWPNonce middleware with a custom exception class so that it can be caught explicitly and transformed into a user-friendly error view.

Proposed solution

 if (! $this->wp->verifyNonce($nonce, $current_path)) {
      throw new HttpException(401, sprintf('Nonce check failed for request path [%s].', $current_path));
 }

We can replace the above code WITHOUT a BC break if we create a new exception class that extends HttpException.

class WPNonceIsInvalid extends HttpException {

//

}

Alternatives

No response

@calvinalkan calvinalkan added the feature New feature or request label Oct 21, 2022
@calvinalkan calvinalkan self-assigned this Oct 21, 2022
calvinalkan added a commit to calvinalkan/snicco that referenced this issue Nov 13, 2022
calvinalkan added a commit to calvinalkan/snicco that referenced this issue Nov 13, 2022
@snicco-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 1.5.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
feature New feature or request released
Projects
None yet
Development

No branches or pull requests

2 participants