本文整理汇总了PHP中app\models\User::validatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::validatePassword方法的具体用法?PHP User::validatePassword怎么用?PHP User::validatePassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::validatePassword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validatePassword
/**
* @param string $attribute
* @param array $params
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
if (!$this->_user->validatePassword($this->{$attribute})) {
$this->addError($attribute, Yii::t('app', 'ERROR_WRONG_CURRENT_PASSWORD'));
}
}
}
示例2: validatePassword
/**
* @param string $attribute
* @param array $params
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
if (!$this->_user->validatePassword($this->{$attribute})) {
$this->addError($attribute, 'Неверный адрес или пароль');
}
}
}
示例3: testUserPasswordValidation
public function testUserPasswordValidation()
{
$user = new User(['username' => 'test', 'email' => 'test@example.com', 'password' => 'secretpassword']);
$this->assertTrue($user->save());
$this->assertNotNull($user->auth_key);
$this->specify('i can validate passwords', function () use($user) {
expect('invalid password is not verified', $user->validatePassword('wrongpw'))->false();
expect('valid password is verified', $user->validatePassword('secretpassword'))->true();
});
}
示例4: changePassword
/**
* Signs user up
*
* @param User $user
* @return User|null the saved model or null if saving fails
*/
public function changePassword($user)
{
if ($this->validate()) {
if ($user->validatePassword($this->currentPassword)) {
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
} else {
$this->addError('currentPassword', 'Current password is incorrect');
}
}
return null;
}
示例5: Auth
/**
* Finds user by username and password
*
* @param string $username
* @param string $password
* @return static|null
*/
public function Auth($username, $password)
{
// username, password are mandatory fields
if (empty($username) || empty($password)) {
return null;
}
// Yii::$app->getSecurity()->generatePasswordHash($this->password);
// get user using requested username
$user = User::findOne(['username' => $username]);
if (empty($user)) {
return null;
}
// validate password
$this->password = $user->password;
$isPass = User::validatePassword($password);
// if password validation fails
if (!$isPass) {
return null;
}
// if user validates (both user_email, user_password are valid)
return $user;
}
示例6: testValidatePassword
public function testValidatePassword()
{
$user = new User();
$user->load($this->user['user1'], false);
$this->assertTrue($user->validatePassword("yiibook"));
}
示例7: userPasswordValidator
public function userPasswordValidator($attribute, $params)
{
if (!$this->_user->validatePassword($this->{$attribute})) {
$this->addError($attribute, 'Please enter correct old password.');
}
}
示例8: testUserValidatePassword
public function testUserValidatePassword()
{
$user = new User();
expect_not($user->validatePassword(''));
$user = User::findByEmail('user-2@example.com');
expect_that($user->validatePassword('123123'));
expect_not($user->validatePassword('test_password'));
}