Kohana_Auth::get_user PHP Method

get_user() public method

Returns FALSE if no user is currently logged in.
public get_user ( ) : mixed
return mixed
    public function get_user()
    {
        return $this->_session->get($this->_config['session_key'], FALSE);
    }

Usage Example

 /**
  * провкрка авторизации по конфигу
  * @return type
  * @throws HTTP_Exception_401
  */
 private function checkAuth()
 {
     if (!class_exists("Kohana_Auth")) {
         return;
     }
     $haveAccess = NULL;
     $authConfig = Kohana::$config->load("structure.kohana.auth");
     $authRoles = explode(",", $authConfig['roles']);
     if ($authConfig['enabled']) {
         $this->auth = Auth::instance();
         $user = $this->auth->get_user();
         if (!$user) {
             throw new HTTP_Exception_401();
         }
         $roles = $user->roles->find_all()->as_array();
         foreach ($roles as $userRole) {
             $userRoles[] = $userRole->name;
         }
         foreach ($userRoles as $currentUserRole) {
             if (in_array($currentUserRole, $authRoles)) {
                 $haveAccess = $currentUserRole;
             }
         }
         if (!$haveAccess) {
             throw new HTTP_Exception_401();
         }
     }
     return $haveAccess;
 }
All Usage Examples Of Kohana_Auth::get_user