This repository was archived by the owner on Sep 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 651
Introduce rest_authorization_required_code()
#1808
Merged
Merged
Conversation
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 function produces a contextually-specific HTTP error code based on whether the user is logged in. It should be used when producing an error from a failed `current_user_can()` check, because it's helpful to the client to be able to distinguish between 401 and 403
Member
Author
|
For the historical artifact, here's all of the places our tests currently fail: |
Member
Author
|
@WP-API/amigos #reviewmerge |
Member
|
I've been thinking about adding either constants for a function to help for a while in a more generic way too, similar to how Symfony does it. Thoughts @WP-API/amigos? |
rmccue
added a commit
that referenced
this pull request
Dec 9, 2015
Introduce `rest_authorization_required_code()`
Member
Author
|
Could. I don't have a strong opinion either way. While I like that HTTP codes are a clear language, using constants instead could help prevent typos from causing egregious bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This function produces a contextually-specific HTTP error code based on
whether the user is logged in. It should be used when producing an error
from a failed
current_user_can()check, because it's helpful to theclient to be able to distinguish between 401 and 403
Fixes #757
Fixes #1665