Example #1
0
 /**
  * @param $controller
  * @param $action
  * @return bool
  * @throws \Acl\AclException
  */
 public function auth($controller, $action)
 {
     $acl = new Acl();
     $user = new User();
     if ($this->session->token) {
         $user_id = A::find(['token' => $this->session->token])[0]->user_id;
         if (!$user_id) {
             $this->reset();
             $user->role_id = 3;
         } else {
             $user = User::find(['id' => $user_id])[0];
         }
     } else {
         $user->role_id = 3;
     }
     $role = Role::find(['id' => $user->role_id])[0]->name;
     if ($acl->isAllowed($role, $controller, $action)) {
         return true;
     } else {
         return false;
     }
 }