private function validateForm()
{
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'));
}
}
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')));
}
}
}