Frontend\Modules\Profiles\Actions\ChangePassword::validateForm PHP Méthode

validateForm() private méthode

Validate the form
private validateForm ( )
    private function validateForm()
    {
        // is the form submitted
        if ($this->frm->isSubmitted()) {
            // get fields
            $txtOldPassword = $this->frm->getField('old_password');
            $txtNewPassword = $this->frm->getField('new_password');
            // old password filled in?
            if ($txtOldPassword->isFilled(FL::getError('PasswordIsRequired'))) {
                // old password correct?
                if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtOldPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
                    // set error
                    $txtOldPassword->addError(FL::getError('InvalidPassword'));
                }
                // new password filled in?
                $txtNewPassword->isFilled(FL::getError('PasswordIsRequired'));
                // passwords match?
                if ($this->frm->getField('new_password')->getValue() !== $this->frm->getField('verify_new_password')->getValue()) {
                    $this->frm->getField('verify_new_password')->addError(FL::err('PasswordsDontMatch'));
                }
            }
            // no errors
            if ($this->frm->isCorrect()) {
                // update password
                FrontendProfilesAuthentication::updatePassword($this->profile->getId(), $txtNewPassword->getValue());
                // trigger event
                FrontendModel::triggerEvent('Profiles', 'after_change_password', array('id' => $this->profile->getId()));
                // redirect
                $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('Profiles', 'ChangePassword') . '?sent=true');
            } else {
                $this->tpl->assign('updatePasswordHasFormError', true);
            }
        }
    }