<commit_before><?php

/**
 * AccountLostPassword is the data structure for keeping account lost password form data.
 * It is used by the 'lostPassword' action of 'AccountUserController'.
 *
 * @property AccountUser $user
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-account-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-account-module/master/LICENSE
 *
 * @package yii-account-module
 */
class AccountLostPassword extends CFormModel
{
    /**
     * @var
     */
    public $email_or_username;

    /**
     * @var
     */
    public $captcha;

    /**
     * @var AccountUser
     */
    private $_user;

    /**
     * Declares the validation rules.
     * @return array
     */
    public function rules()
    {
        return array(
            array('email_or_username', 'required'),
            array('email_or_username', 'checkExists'),
        );
    }

    /**
     * Declares attribute labels.
     * @return array
     */
    public function attributeLabels()
    {
        return array(
            'email_or_username' => Yii::t('account', 'Username or Email'),
            'captcha' => Yii::t('account', 'Enter both words separated by a space'),
        );
    }

    /**
     * Checks if the user exists.
     * This is the 'validateCurrentPassword' validator as declared in rules().
     * @param $attribute
     */
    public function checkExists($attribute)
    {
        if (!$this->$attribute)
            return;
        if (!$this->user)
            $this->addError($attribute, strpos($this->$attribute, '@') ? Yii::t('account', 'Email is incorrect.') : Yii::t('account', 'Username is incorrect.'));
    }

    /**
     * @return bool
     */
    public function beforeValidate()
    {
        /** @var AccountModule $account */
        $account = Yii::app()->getModule('account');
        if ($account->reCaptcha) {
            Yii::import('account.components.AccountReCaptchaValidator');
            $validator = new AccountReCaptchaValidator;
            $validator->attributes = array('captcha');
            $validator->validate($this);
            if ($this->hasErrors('captcha'))
                return false;
        }
        return parent::beforeValidate();
    }

    /**
     * @return AccountUser
     */
    public function getUser()
    {
        if (!$this->_user) {
            /** @var AccountModule $account */<commit_msg>better validation message<commit_after><?php

/**
 * AccountLostPassword is the data structure for keeping account lost password form data.
 * It is used by the 'lostPassword' action of 'AccountUserController'.
 *
 * @property AccountUser $user
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-account-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-account-module/master/LICENSE
 *
 * @package yii-account-module
 */
class AccountLostPassword extends CFormModel
{
    /**
     * @var
     */
    public $email_or_username;

    /**
     * @var
     */
    public $captcha;

    /**
     * @var AccountUser
     */
    private $_user;

    /**
     * Declares the validation rules.
     * @return array
     */
    public function rules()
    {
        return array(
            array('email_or_username', 'required'),
            array('email_or_username', 'checkExists'),
        );
    }

    /**
     * Declares attribute labels.
     * @return array
     */
    public function attributeLabels()
    {
        return array(
            'email_or_username' => Yii::t('account', 'Username or Email'),
            'captcha' => Yii::t('account', 'Enter both words separated by a space'),
        );
    }

    /**
     * Checks if the user exists.
     * This is the 'validateCurrentPassword' validator as declared in rules().
     * @param $attribute
     */
    public function checkExists($attribute)
    {
        if (!$this->$attribute)
            return;
        if (!$this->user)
            $this->addError($attribute, strpos($this->$attribute, '@') ? Yii::t('account', 'Email does not exist.') : Yii::t('account', 'Username does not exist.'));
    }

    /**
     * @return bool
     */
    public function beforeValidate()
    {
        /** @var AccountModule $account */
        $account = Yii::app()->getModule('account');
        if ($account->reCaptcha) {
            Yii::import('account.components.AccountReCaptchaValidator');
            $validator = new AccountReCaptchaValidator;
            $validator->attributes = array('captcha');
            $validator->validate($this);
            if ($this->hasErrors('captcha'))
                return false;
        }
        return parent::beforeValidate();
    }

    /**
     * @return AccountUser
     */
    public function getUser()
    {
        if (!$this->_user) {
            /** @var AccountModule $account */
{'fraction_non_alphanumeric': 0.14331853048041987, 'fraction_numerical': 0.0020185708518368995, 'mean_word_length': 2.1988379599741767, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3937801', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1384, 'n_words': 332}