PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.2
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.2
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Http / Policies / SubmissionPolicy.php

SubmissionPolicy.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.2, at app/Http/Policies/SubmissionPolicy.php

82 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Http\Policies;
4
5 use FluentForm\App\Models\Submission;
6 use FluentForm\App\Modules\Acl\Acl;
7 use FluentForm\Framework\Http\Request\Request;
8 use FluentForm\Framework\Foundation\Policy;
9
10 class SubmissionPolicy extends Policy
11 {
12 /**
13 * Check permission for any method
14 *
15 * @param \FluentForm\Framework\Request\Request $request
16 * @return bool
17 */
18 public function verifyRequest(Request $request)
19 {
20 $formId = $this->resolveFormId($request);
21 return Acl::hasPermission('fluentform_entries_viewer', $formId);
22 }
23
24 public function handleBulkActions(Request $request)
25 {
26 $formId = $this->resolveFormId($request);
27 return Acl::hasPermission('fluentform_manage_entries', $formId);
28 }
29
30 public function store(Request $request)
31 {
32 return $this->handleBulkActions($request);
33 }
34
35 public function updateStatus(Request $request)
36 {
37 return $this->handleBulkActions($request);
38 }
39
40 public function toggleIsFavorite(Request $request)
41 {
42 return $this->handleBulkActions($request);
43 }
44
45 public function remove(Request $request)
46 {
47 return $this->handleBulkActions($request);
48 }
49
50 public function print(Request $request)
51 {
52 return $this->handleBulkActions($request);
53 }
54
55 public function updateSubmissionUser(Request $request)
56 {
57 // Controller now uses entry_id from route as the mutation target,
58 // so authorization and mutation are always the same record.
59 $formId = $this->resolveFormId($request);
60 return Acl::hasPermission('fluentform_manage_entries', $formId);
61 }
62
63 /**
64 * Resolve the form_id for authorization.
65 * For entry-scoped routes, always derive from the entry record to prevent
66 * attackers from passing an allowed form_id while targeting another form's entry.
67 */
68 private function resolveFormId(Request $request)
69 {
70 $entryId = $request->get('entry_id');
71 if ($entryId) {
72 $submission = Submission::select('form_id')->find(intval($entryId));
73 if ($submission) {
74 return $submission->form_id;
75 }
76 }
77
78 $formId = $request->get('form_id');
79 return $formId ? intval($formId) : null;
80 }
81 }
82