src/Auth/AuthMiddleware.php
public function isAdmin($redirect = false)
    {

        if (!$this->isLoggedIn()) {
            $this->di->get("response")->redirect("user/login");
            return false;
        }

        $email = $this->di->get("session")->get("user");
        $user = new User();
        $user->setDb($this->di->get("db"));
        $user->find("email", $email);
        $isAdmin = $user->admin;

        if (!$isAdmin) {
            if ($redirect) {
                $this->di->get("response")->redirect("user");
            }
            return false;
        }

        return true;
    }
public function isAdmin($redirect = false)
    {

        if (!$this->isLoggedIn()) {
            $this->di->get("response")->redirect("user/login");
            return false;
        }

        $email = $this->di->get("session")->get("user");
        $user = new User();
        $user->setDb($this->di->get("db"));
        $user->find("email", $email);
        $isAdmin = $user->admin;

        if (!$isAdmin) {
            if ($redirect) {
                $this->di->get("response")->redirect("user");
            }
            return false;
        }

        return true;
    }
public function isAdmin ( $ redirect = false ) { if ( ! $ this -> isLoggedIn ( ) ) { $ this -> di -> get ( "response" ) -> redirect ( "user/login" ) ; return false ; } $ email = $ this -> di -> get ( "session" ) -> get ( "user" ) ; $ user = new User ( ) ; $ user -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user -> find ( "email" , $ email ) ; $ isAdmin = $ user -> admin ; if ( ! $ isAdmin ) { if ( $ redirect ) { $ this -> di -> get ( "response" ) -> redirect ( "user" ) ; } return false ; } return true ; }
Check if user is admin

@param string $email user email

@return boolean if the user is an admin
Check if user is admin