Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | protected function checkPermissions(string $modifier, mixed ...$params): bool |
||
23 | { |
||
24 | |||
25 | if($modifier == LoginRequired::class) { |
||
26 | $level = $params[0] ?? 1; |
||
27 | |||
28 | $authenticator = new \Lepton\Authenticator\UserAuthenticator(); |
||
29 | $loggedIn = $authenticator->isLoggedIn(); |
||
30 | if(! $loggedIn) { |
||
31 | return false; |
||
32 | } |
||
33 | $user = $authenticator->getLoggedUser(); |
||
34 | $splitted = explode("__", $this->level_field); |
||
35 | $user_level = $user; |
||
36 | foreach($splitted as $part) { |
||
37 | $user_level = $user_level->$part; |
||
38 | } |
||
39 | return ($user_level >= $level); |
||
40 | } |
||
41 | return true; |
||
42 | } |
||
44 |