@@ -20,11 +20,11 @@ |
||
20 | 20 | public function hasPermission(PermissionInterface $permission) : bool; |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * Retrieve the permissions associated with the user's roles. |
|
25 | - * |
|
26 | - * @return array An array of permissions associated with the user's roles. |
|
27 | - */ |
|
23 | + /** |
|
24 | + * Retrieve the permissions associated with the user's roles. |
|
25 | + * |
|
26 | + * @return array An array of permissions associated with the user's roles. |
|
27 | + */ |
|
28 | 28 | public function getPermissions() : array; |
29 | 29 | |
30 | 30 |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $this->rbac_class = $middlewareParams["rbac_class"] ?? throw new \Exception("You have to define a RBAC class"); |
21 | 21 | |
22 | 22 | $rbac_interfaces = class_implements($this->rbac_class); |
23 | - if(! in_array(\Lepton\Authenticator\RBAC\RBACInterface::class, $rbac_interfaces)) { |
|
23 | + if (!in_array(\Lepton\Authenticator\RBAC\RBACInterface::class, $rbac_interfaces)) { |
|
24 | 24 | throw new \Exception("RBAC class has to implement \Lepton\Authenticator\RBAC\RBACInterface"); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $this->user_class = $middlewareParams["user_class"] ?? throw new \Exception("You have to define a User class"); |
28 | 28 | |
29 | 29 | $user_interfaces = class_implements($this->user_class); |
30 | - if(! in_array(\Lepton\Authenticator\RBAC\UserInterface::class, $user_interfaces)) { |
|
30 | + if (!in_array(\Lepton\Authenticator\RBAC\UserInterface::class, $user_interfaces)) { |
|
31 | 31 | throw new \Exception("User class has to implement \Lepton\Authenticator\RBAC\UserInterface"); |
32 | 32 | } |
33 | 33 | |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | protected function checkPermissions(string $modifier, mixed ...$params): bool |
39 | 39 | { |
40 | 40 | |
41 | - if($modifier == LoginRequired::class) { |
|
41 | + if ($modifier == LoginRequired::class) { |
|
42 | 42 | |
43 | 43 | $level = isset($params[0]) ? $params[0] : 1; |
44 | 44 | $authenticator = new \Lepton\Authenticator\UserAuthenticator(); |
45 | 45 | $loggedIn = $authenticator->isLoggedIn(); |
46 | - if(! $loggedIn) { |
|
46 | + if (!$loggedIn) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | $user = $authenticator->getLoggedUser(); |
50 | 50 | $num_privileges = $user->privileges->and(livello__gte: $level)->count(); |
51 | 51 | return ($num_privileges > 0); |
52 | - } elseif($modifier == PermissionRequired::class){ |
|
52 | + } elseif ($modifier == PermissionRequired::class) { |
|
53 | 53 | $user = (new UserAuthenticator)->getLoggedUser(); |
54 | 54 | die(print_r($params)); |
55 | 55 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $user = $authenticator->getLoggedUser(); |
50 | 50 | $num_privileges = $user->privileges->and(livello__gte: $level)->count(); |
51 | 51 | return ($num_privileges > 0); |
52 | - } elseif($modifier == PermissionRequired::class){ |
|
52 | + } elseif($modifier == PermissionRequired::class) { |
|
53 | 53 | $user = (new UserAuthenticator)->getLoggedUser(); |
54 | 54 | die(print_r($params)); |
55 | 55 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Lepton\Http\Response; |
4 | 4 | |
5 | - class JSONResponse extends SuccessResponse |
|
5 | + class JSONResponse extends SuccessResponse |
|
6 | 6 | { |
7 | 7 | |
8 | 8 | public function __construct( |
@@ -12,7 +12,7 @@ |
||
12 | 12 | parent::__construct(headers: ["Content-Type" => "application/json"]); |
13 | 13 | } |
14 | 14 | |
15 | - public function sendBody(){ |
|
15 | + public function sendBody() { |
|
16 | 16 | echo json_encode($this->array); |
17 | 17 | } |
18 | 18 |