function run() { $sError = false; $this->setTitle($this->t_('title')); if (AnwEnv::_POST("submit")) { $sLogin = AnwEnv::_POST("login", ""); $sPassword = AnwEnv::_POST("password", ""); $bRememberMe = AnwSessions::isResumeEnabled() && AnwEnv::_POST("remember") ? true : false; $sUrlRedirect = AnwEnv::_POST("redirect", ""); try { //try to authenticate and open the session AnwCurrentSession::login($sLogin, $sPassword, $bRememberMe); $this->redirectInfo($sUrlRedirect, $this->t_("t_loggedin"), $this->t_("p_loggedin")); } catch (AnwAuthException $e) { $sError = $this->g_("err_auth"); } catch (AnwBadLoginException $e) { $sError = $this->g_("err_badlogin"); } catch (AnwBadPasswordException $e) { $sError = $this->g_("err_badpassword"); } //error occurred, display again the login form $this->showLoginForm($sLogin, $sUrlRedirect, $bRememberMe, $sError); } else { //arriving on the form $this->showLoginForm("", AnwEnv::_GET("redirect", ""), false); } }
function run() { if (!self::globalCfgUsersRegisterEnabled()) { AnwUtils::redirect(); } $this->setTitle($this->t_('title')); $sError = false; $sLogin = ""; $sDisplayName = ""; $sEmail = ""; if (AnwEnv::_POST("submit")) { $sLogin = AnwEnv::_POST("login", ""); $sDisplayName = AnwEnv::_POST("displayname", ""); $sEmail = AnwEnv::_POST("email", ""); $sPassword = AnwEnv::_POST("password", ""); //try to register try { $this->checkCaptcha(); $sLang = AnwCurrentSession::getLang(); $nTimezone = AnwCurrentSession::getTimezone(); $oUser = AnwUsers::createUser($sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone, $sPassword); AnwCurrentSession::login($sLogin, $sPassword, false); //open a public time-limited session $this->redirectInfo(false, $this->t_("t_created"), $this->t_("p_created")); } catch (AnwLoginAlreadyTakenException $e) { $sError = $this->g_("err_loginalreadytaken"); } catch (AnwBadLoginException $e) { $sError = $this->g_("err_badlogin"); } catch (AnwDisplayNameAlreadyTakenException $e) { $sError = $this->g_("err_displaynamealreadytaken"); } catch (AnwBadDisplayNameException $e) { $sError = $this->g_("err_baddisplayname"); } catch (AnwEmailAlreadyTakenException $e) { $sError = $this->g_("err_emailalreadytaken"); } catch (AnwBadEmailException $e) { $sError = $this->g_("err_bademail"); } catch (AnwBadPasswordException $e) { $sError = $this->g_("err_badpassword"); } catch (AnwBadCaptchaException $e) { $sError = $this->g_("err_badcaptcha"); } } //display register form $this->out .= $this->tpl()->registerForm(AnwUtils::alink("register"), $sLogin, $sDisplayName, $sEmail, $sError); }