Auth::checkAdminAuthentication PHP Method

checkAdminAuthentication() public static method

If user is not, then he will be redirected to login page and the application is hard-stopped via exit(). Using this method makes only sense in controllers that should only be used by admins.
public static checkAdminAuthentication ( )
    public static function checkAdminAuthentication()
    {
        // initialize the session (if not initialized yet)
        Session::init();
        // self::checkSessionConcurrency();
        // if user is not logged in or is not an admin (= not role type 7)
        if (!Session::userIsLoggedIn() || Session::get("user_account_type") != 7) {
            // ... then treat user as "not logged in", destroy session, redirect to login page
            Session::destroy();
            header('location: ' . Config::get('URL') . 'login');
            // to prevent fetching views via cURL (which "ignores" the header-redirect above) we leave the application
            // the hard way, via exit(). @see https://github.com/panique/php-login/issues/453
            // this is not optimal and will be fixed in future releases
            exit;
        }
    }

Usage Example

 /**
  * Construct this object by extending the basic Controller class
  */
 public function __construct()
 {
     parent::__construct();
     // special authentication check for the entire controller: Note the check-ADMIN-authentication!
     // All methods inside this controller are only accessible for admins (= users that have role type 7)
     Auth::checkAdminAuthentication();
 }
All Usage Examples Of Auth::checkAdminAuthentication