Skip to content

Commit 5e86c51

Browse files
committed
fixes broken access control in form submission
1 parent 3e88f7e commit 5e86c51

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

assets/wpuf/js/frontend-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@
450450
type: 'warning',
451451
showCancelButton: false,
452452
confirmButtonColor: '#d54e21',
453-
confirmButtonText: 'OK',
453+
confirmButtonText: 'Ok',
454454
cancelButtonClass: 'btn btn-danger',
455455
});
456456

includes/class-ajax.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,20 @@ public function handle_frontend_submission() {
711711
check_ajax_referer( 'wpuf_form_add' );
712712
$form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
713713
$page_id = isset( $_POST['page_id'] ) ? intval( $_POST['page_id'] ) : 0;
714-
715714
$form = weforms()->form->get( $form_id );
715+
716+
/**
717+
* Check if form submission is open. This resolves broken access control with unauthenticated users.
718+
* Access is now checked on frontend form rendering and submission.
719+
*/
720+
$form_submission_status = $form->is_submission_open();
721+
if ( is_wp_error( $form_submission_status ) ) {
722+
wp_send_json( [
723+
'success' => false,
724+
'error' => __( 'Login Required for submission.', 'weforms' ),
725+
] );
726+
}
727+
716728
$form_settings = $form->get_settings();
717729
$form_fields = $form->get_fields();
718730
$entry_fields = $form->prepare_entries();
@@ -1241,4 +1253,16 @@ public function delete_logs() {
12411253

12421254
wp_send_json_success();
12431255
}
1256+
1257+
/**
1258+
* Show form error
1259+
*
1260+
* @param string $message
1261+
* @param string $type
1262+
*
1263+
* @return string
1264+
*/
1265+
public function show_error( $message, $type = 'info' ) {
1266+
return sprintf( '<div class="wpuf-%s">%s</div>', $type, $message );
1267+
}
12441268
}

0 commit comments

Comments
 (0)