/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted if ($this->frm->isSubmitted()) { // shorten fields $newPassword = $this->frm->getField('backend_new_password'); $newPasswordRepeated = $this->frm->getField('backend_new_password_repeated'); // required fields $newPassword->isFilled(BL::err('PasswordIsRequired')); $newPasswordRepeated->isFilled(BL::err('PasswordRepeatIsRequired')); // all fields are ok? if ($newPassword->isFilled() && $newPasswordRepeated->isFilled()) { // the passwords entered match if ($newPassword->getValue() !== $newPasswordRepeated->getValue()) { // add error $this->frm->addError(BL::err('PasswordsDontMatch')); // show error $this->tpl->assign('error', BL::err('PasswordsDontMatch')); } } // is the form submitted if ($this->frm->isCorrect()) { // change the users password BackendUsersModel::updatePassword($this->user, $newPassword->getValue()); // attempt to login the user if (!BackendAuthentication::loginUser($this->user->getEmail(), $newPassword->getValue())) { // redirect to the login form with an error $this->redirect(BackendModel::createURLForAction('index', null, null, array('login' => 'failed'))); } // redirect to the login form $this->redirect(BackendModel::createUrlForAction('index', 'dashboard', null, array('password_reset' => 'success'))); } } }