PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Http / Policies / AdvanceFilterPolicy.php

AdvanceFilterPolicy.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Http/Policies/AdvanceFilterPolicy.php

43 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Http\Policies;
4
5 use FluentCart\App\Services\Permission\PermissionManager;
6 use FluentCart\Framework\Http\Request\Request;
7
8 /**
9 * Unlike the other policies here, this one deliberately does not read the
10 * route's permission meta.
11 *
12 * The endpoint it guards serves many unrelated data sets behind one URL —
13 * product variations, labels, attributes, tax states — so a single route-level
14 * permission would have to be the union of all of them, and would let anyone
15 * holding the weakest one read the data behind the strongest. The check that
16 * matters is per data key, and only the controller knows which key was asked
17 * for.
18 *
19 * So this is the outer door: it keeps non-admins out entirely, and leaves
20 * AdvanceFilterController::resolvePermission() to decide who may read what.
21 *
22 * @package FluentCart\App\Http\Policies
23 *
24 * @version 1.0.0
25 */
26 class AdvanceFilterPolicy extends Policy
27 {
28 /**
29 * @param Request $request
30 * @return bool
31 */
32 public function verifyRequest(Request $request): bool
33 {
34 /*
35 * getUserPermissions() is empty for anyone without a FluentCart role,
36 * which is the distinction wanted here — a logged-in customer must not
37 * reach the controller at all. Deliberately not Helper::getCurrentUser(),
38 * which resolves for every logged-in WordPress user.
39 */
40 return !empty(PermissionManager::getUserPermissions());
41 }
42 }
43