amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

Authentication error #189

Closed parthasarathi2015 closed 7 years ago

parthasarathi2015 commented 7 years ago

Unknown Property – yii\base\UnknownPropertyException

Getting unknown property: common\models\User::password_hash in E:\xampp\htdocs\yii2\vendor\yiisoft\yii2\base\Component.php at line 147 138139140141142143144145146147148149150151152153154155156

        if ($behavior->canGetProperty($name)) {
            return $behavior->$name;
        }
    }

    if (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }

    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

/**
 * Sets the value of a component property.
 * This method will check in the following order and act accordingly:
 *
 *  - a property defined by a setter: set the property value
 *  - an event in the format of "on xyz": attach the handler to the event "xyz"
 *  - a behavior in the format of "as xyz": attach the behavior named as "xyz"
  1. in E:\xampp\htdocs\yii2\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 286 – yii\base\Component::__get('password_hash')

  2. in E:\xampp\htdocs\yii2\common\models\User.php at line 153 – yii\db\BaseActiveRecord::__get('password_hash') 147148149150151152153154155156157158159

    *

    • @param string $password password to validate
    • @return bool if password provided is valid for current user */ public function validatePassword($password) { return Yii::$app->security->validatePassword($password, $this->password_hash); }

    /**

    • Generates password hash from password and sets it to the model
    • @param string $password
  3. in E:\xampp\htdocs\yii2\common\models\LoginForm.php at line 45 – common\models\User::validatePassword('111111') 39404142434445464748495051

    • @param array $params the additional name-value pairs given in the rule */ public function validatePassword($attribute, $params) { if (!$this->hasErrors()) { $user = $this->getUser(); if (!$user || !$user->validatePassword($this->password)) { $this->addError($attribute, 'Incorrect username or password.'); } } }

    /**

  4. common\models\LoginForm::validatePassword('password', null, yii\validators\InlineValidator)

  5. in E:\xampp\htdocs\yii2\vendor\yiisoft\yii2\validators\InlineValidator.php at line 72 – call_user_func([common\models\LoginForm, 'validatePassword'], 'password', null, yii\validators\InlineValidator)

amnah commented 7 years ago

go to user/login instead of site/login

amnah commented 7 years ago

added a note in the readme for this 5256767e3c366f5638f79b1db10197bb97aff93d