public function execute(HTTPRequestCustom $request) { $this->init($request); $this->build_form(); if ($this->request->get_bool('disconnect', false)) { AppContext::get_session()->csrf_get_protect(); $session = AppContext::get_session(); Session::delete($session); AppContext::get_response()->redirect($this->get_redirect_url()); } if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) { if (!$this->maintain_config->is_under_maintenance() || $this->maintain_config->is_under_maintenance() && $this->maintain_config->is_authorized_in_maintenance()) { if ($this->request->get_value('redirect', '') || $this->redirect !== null) { AppContext::get_response()->redirect($this->get_redirect_url()); } else { AppContext::get_response()->redirect(Environment::get_home_page()); } } } $authenticate_type = $this->request->get_value('authenticate', false); if ($authenticate_type) { if ($authenticate_type == PHPBoostAuthenticationMethod::AUTHENTICATION_METHOD) { $login = $this->request->get_value('login', ''); $password = $this->request->get_value('password', ''); $autoconnect = $this->request->get_bool('autoconnect', false); $this->phpboost_authenticate($login, $password, $autoconnect); } else { try { $authentication = AuthenticationService::get_authentication_method($authenticate_type); } catch (Exception $e) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $this->authenticate($authentication, true); } } if ($this->submit_button->has_been_submited() && $this->form->validate()) { $login = $this->form->get_value('login'); $password = $this->form->get_value('password'); $autoconnect = $this->form->get_value('autoconnect'); $this->phpboost_authenticate($login, $password, $autoconnect); } $this->init_vars_template(); return $this->build_view(); }
public function execute(HTTPRequestCustom $request) { $this->init(); $user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id()); try { $this->user = UserService::get_user($user_id); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } try { $this->internal_auth_infos = PHPBoostAuthenticationMethod::get_auth_infos($user_id); } catch (RowNotFoundException $e) { } $this->user_auth_types = AuthenticationService::get_user_types_authentication($user_id); if (!$this->check_authorizations($user_id)) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } $associate_type = $request->get_getvalue('associate', false); if ($associate_type) { if (!in_array($associate_type, $this->user_auth_types)) { $authentication_method = AuthenticationService::get_authentication_method($associate_type); AuthenticationService::associate($authentication_method, $user_id); AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id)); } } $dissociate_type = $request->get_getvalue('dissociate', false); if ($dissociate_type) { if (in_array($dissociate_type, $this->user_auth_types) && count($this->user_auth_types) > 1) { $authentication_method = AuthenticationService::get_authentication_method($dissociate_type); AuthenticationService::dissociate($authentication_method, $user_id); AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id)); } } $this->build_form(); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save($request); } $this->tpl->put('FORM', $this->form->display()); return $this->build_response(); }