POST Forms: Nonce fields according to current action#38
Merged
Conversation
… edit) + tests for default layout
…to avoid special cases according to method/action
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi @zinigor!
As I mentioned in this comment on a previous pull request, I think we need to update the way we handle nonces
This pull request does the following changes:
get_nonce_action()fromUrlBuildertoDataViewConfig_wpnonce) to use an action specific one (_wpnonce_{action}))The reason I moved
get_nonce_action()away fromUrlBuilderis because we also use it to generate nonce fields in our POST<form>, and as it relies onget_menu_page()to generate the nonce action name I thought it could make sense to move it toDataViewConfig(honestly wasn't really sure what would be the best place)The default layout was returning a "Save" and "Delete" button for the create action, we should now display only a "Create" button instead
Lastly, it switch from the default name for the nonce field (
_wpnonce) to an action specific name. It was causing issues in the edit form, as we need a 2 nonce fields (2 actions in the same form: edit and delete). Both actions require a different nonce in the backend (here and here), so we have to use a different name otherwise the second nonce will overwrite the first one