Example #1
0
 /**
  * Method checks if admin panel route is open and then valid permission to
  * stay there. If user is admin (or moderator) method loads necessary extensions
  */
 public function loadAdmin()
 {
     if ($this->http->isAdmin()) {
         // If not logged open login panel
         if (!$this->user->isUserLoggedIn()) {
             $this->view->loadFile('../../admin/extensions/Index/login.html');
             exit;
         }
         // Check permissions
         if ($this->user->getUserSession()->getRole() != 'admin') {
             Server::headerLocation();
             // Go to main page
         }
         // Admin view helper classes
         $this->viewHelper->add($this->conf['adminViewHelper'] ?? []);
         $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml));
     }
 }
Example #2
0
 /**
  *
  * @param \UserAuth\User $user
  */
 private function checkIfUserIsLogged(\UserAuth\User $user)
 {
     if (!$user->isUserLoggedIn()) {
         Server::headerLocationReferer();
     }
 }
Example #3
0
 /**
  *
  * @return string
  */
 public function getUserRole() : string
 {
     return $this->user->getUserSession()->getRole();
 }