| Total Complexity | 8 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class Auth extends Module |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * get the user type |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | public function getUser() |
||
| 21 | { |
||
| 22 | $session = $this->container->getSession(); |
||
| 23 | return $session->get('user_role_name'); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Gets the user level defined in the session (this is set on login and also stored in the DB). |
||
| 28 | * Returns an int for easier user control. |
||
| 29 | * @return int |
||
| 30 | */ |
||
| 31 | public function getUserLevel(): int |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Gets the user role name |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | public function getUserRole():string |
||
| 42 | { |
||
| 43 | $session = $this->container->getSession(); |
||
| 44 | return $session->get('user_role_name') ?? ''; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * gets the configured levels defined in the constant file |
||
| 49 | * @return \stdClass |
||
| 50 | */ |
||
| 51 | public function getLevelConst():\stdClass |
||
| 52 | { |
||
| 53 | $levels = new \stdClass(); |
||
| 54 | $levels->userLevel = Constant::USER_LEVEL; |
||
| 55 | $levels->adminLevel = Constant::ADMIN_LEVEL; |
||
| 56 | |||
| 57 | return $levels; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * is the connected user an Admin |
||
| 62 | * @return bool |
||
| 63 | */ |
||
| 64 | public function isAdmin():bool |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * is the user connected ? |
||
| 75 | * @return bool |
||
| 76 | */ |
||
| 77 | public function isUser():bool |
||
| 84 | } |
||
| 85 | } |