private function authenticate(AuthenticationMethod $authentication, $autoconnect) { $user_id = AuthenticationService::authenticate($authentication, $autoconnect); $current_user = CurrentUser::from_session(); if ($user_id && $this->maintain_config->is_under_maintenance() && !$current_user->check_auth($this->maintain_config->get_auth(), MaintenanceConfig::ACCESS_WHEN_MAINTAIN_ENABLED_AUTHORIZATIONS)) { $session = AppContext::get_session(); Session::delete($session); $this->view->put('ERROR_MESSAGE', MessageHelper::display(LangLoader::get_message('user.not_authorized_during_maintain', 'status-messages-common'), MessageHelper::NOTICE)); $this->has_error = true; } else { if ($user_id) { AppContext::get_response()->redirect($this->get_redirect_url()); } if ($authentication->has_error()) { $this->view->put('ERROR_MESSAGE', MessageHelper::display($authentication->get_error_msg(), MessageHelper::NOTICE)); $this->has_error = true; } } }
/** * Returns the current user * @return CurrentUser */ public static function get_current_user() { if (self::$current_user === null) { self::$current_user = CurrentUser::from_session(); } return self::$current_user; }