Redaxscript\Controller\Login::_validate PHP Method

_validate() protected method

validate
Since: 3.0.0
protected _validate ( array $postArray = [], object $user = null ) : array
$postArray array array of the post
$user object object of the user
return array
    protected function _validate($postArray = [], $user = null)
    {
        $passwordValidator = new Validator\Password();
        $captchaValidator = new Validator\Captcha();
        /* validate post */
        $messageArray = [];
        if (!$postArray['user']) {
            $messageArray[] = $this->_language->get('user_empty');
        } else {
            if (!$user->id) {
                $messageArray[] = $this->_language->get('user_incorrect');
            }
        }
        if (!$postArray['password']) {
            $messageArray[] = $this->_language->get('password_empty');
        } else {
            if ($user->password && $passwordValidator->validate($postArray['password'], $user->password) === Validator\ValidatorInterface::FAILED) {
                $messageArray[] = $this->_language->get('password_incorrect');
            }
        }
        if (Db::getSetting('captcha') > 0 && $captchaValidator->validate($postArray['task'], $postArray['solution']) === Validator\ValidatorInterface::FAILED) {
            $messageArray[] = $this->_language->get('captcha_incorrect');
        }
        return $messageArray;
    }