/** * Registration form submit (registration page version) * @param AjaxCheckbox $accept * @param AjaxCheckbox $redirect * @param AjaxString|null $email * @param AjaxString|null $password1 * @param AjaxString|null $password2 * @param AjaxString|null $login * @param AjaxString|null $capcha * @throws Exception */ public function submitAjaxAction(AjaxCheckbox $accept, AjaxCheckbox $redirect, AjaxString $email = null, AjaxString $password1 = null, AjaxString $password2 = null, AjaxString $login = null, AjaxString $capcha = null) { $register = new Users\Register(); $register->setEmail($email); $register->setLogin($login); $register->setPassword1($password1); $register->setPassword2($password2); $register->setCaptcha($capcha); if (!$register->validate()) { $register->callAjaxerEvents(); return; } // EULA if (!$accept->val() and \Difra\Config::getInstance()->getValue('auth', 'eula')) { $this->root->appendChild($this->xml->createElement('eula')); Ajaxer::display(View::render($this->xml, 'auth-ajax', true)); return; } $register->register(); $this->afterSuccess(); }
/** * Change password * @param Difra\Param\AjaxString $oldpassword * @param Difra\Param\AjaxString $password1 * @param Difra\Param\AjaxString $password2 */ public function passwordAjaxActionAuth(Param\AjaxString $oldpassword, Param\AjaxString $password1, Param\AjaxString $password2) { $user = User::getCurrent(); if (!$user->verifyPassword($oldpassword)) { Ajaxer::status('oldpassword', Locales::get('auth/password/bad_old'), 'problem'); $ok = false; } else { $ok = true; } $reg = new Register(); $reg->setPassword1($password1->val()); $reg->setPassword2($password2->val()); if (!$reg->validatePasswords()) { if ($ok) { Ajaxer::status('oldpassword', Locales::get('auth/password/old_ok'), 'ok'); } $reg->callAjaxerEvents(); return; } if (!$ok) { return; } $user->setPassword($password1->val()); $this->afterPasswordChangeAjax(); }