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

fix: nonce verification issue during checkout is fixed #518 #519

Merged
merged 1 commit into from
Jan 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions includes/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function render_shortcode() {
* @return \WP_Error
*/
function validate_registration( $error ) {

if ( is_checkout() ) {
return $error;
}

$post_data = wp_unslash( $_POST );

$nonce_value = isset( $post_data['_wpnonce'] ) ? $post_data['_wpnonce'] : '';
Expand Down Expand Up @@ -100,13 +105,6 @@ function validate_registration( $error ) {
function set_new_vendor_names( $data ) {
$post_data = wp_unslash( $_POST );

$nonce_value = isset( $post_data['_wpnonce'] ) ? $post_data['_wpnonce'] : '';
$nonce_value = isset( $post_data['woocommerce-register-nonce'] ) ? $post_data['woocommerce-register-nonce'] : $nonce_value;

if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-register' ) ) {
return new WP_Error( 'nonce_verification_failed', __( 'Nonce verification failed', 'dokan-lite' ) );
}

$allowed_roles = array( 'customer', 'seller' );
$role = ( isset( $post_data['role'] ) && in_array( $post_data['role'], $allowed_roles ) ) ? $post_data['role'] : 'customer';

Expand Down Expand Up @@ -134,14 +132,7 @@ function set_new_vendor_names( $data ) {
function save_vendor_info( $user_id, $data ) {
$post_data = wp_unslash( $_POST );

$nonce_value = isset( $post_data['_wpnonce'] ) ? $post_data['_wpnonce'] : '';
$nonce_value = isset( $post_data['woocommerce-register-nonce'] ) ? $post_data['woocommerce-register-nonce'] : $nonce_value;

if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-register' ) ) {
return new WP_Error( 'nonce_verification_failed', __( 'Nonce verification failed', 'dokan-lite' ) );
}

if ( $data['role'] != 'seller' ) {
if ( ! isset( $data['role'] ) || $data['role'] != 'seller' ) {
return;
}

Expand Down