Skip to content

Commit

Permalink
fix(form): verify nonce when changing payment method
Browse files Browse the repository at this point in the history
ref #2580
  • Loading branch information
ravinderk committed Aug 1, 2018
1 parent ab10978 commit 75fb458
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion assets/src/js/frontend/give-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ function give_load_gateway( form_object, payment_mode ) {
give_total: give_total,
give_form_id: give_form_id,
give_form_id_prefix: give_form_id_prefix,
give_payment_mode: payment_mode
give_payment_mode: payment_mode,
nonce: Give.form.fn.getNonce( form_object )
},
function( response ) {
//Success: let's output the gateway fields in the appropriate form space
Expand Down
6 changes: 5 additions & 1 deletion includes/gateways/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ function give_load_ajax_gateway() {

$post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok.

if ( isset( $post_data['give_payment_mode'] ) ) {
if ( ! give_verify_donation_form_nonce( $post_data['nonce'], $post_data['give_form_id'] ) ) {
Give_Notices::print_frontend_notice( __( 'Nonce verification has failed.', 'give' ), true, 'error' );
exit();

}elseif ( isset( $post_data['give_payment_mode'] ) ) {

$form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : '';

Expand Down

0 comments on commit 75fb458

Please sign in to comment.