mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-30 14:37:20 +08:00
pull origin
This commit is contained in:
@@ -33,13 +33,16 @@ class LoginForm extends Model
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword()
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->hasErrors()) {
|
||||
$user = $this->getUser();
|
||||
if (!$user || !$user->validatePassword($this->password)) {
|
||||
$this->addError('password', 'Incorrect username or password.');
|
||||
$this->addError($attribute, 'Incorrect username or password.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
*/
|
||||
public function generateAuthKey()
|
||||
{
|
||||
$this->auth_key = Yii::$app->security->generateRandomKey();
|
||||
$this->auth_key = Yii::$app->security->generateRandomString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
*/
|
||||
public function generatePasswordResetToken()
|
||||
{
|
||||
$this->password_reset_token = Yii::$app->security->generateRandomKey() . '_' . time();
|
||||
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
return [
|
||||
'username' => 'userName',
|
||||
'auth_key' => function ($fixture, $faker, $index) {
|
||||
$fixture['auth_key'] = Yii::$app->getSecurity()->generateRandomKey();
|
||||
$fixture['auth_key'] = Yii::$app->getSecurity()->generateRandomString();
|
||||
|
||||
return $fixture;
|
||||
},
|
||||
@@ -13,7 +13,7 @@ return [
|
||||
return $fixture;
|
||||
},
|
||||
'password_reset_token' => function ($fixture, $faker, $index) {
|
||||
$fixture['password_reset_token'] = Yii::$app->getSecurity()->generateRandomKey() . '_' . time();
|
||||
$fixture['password_reset_token'] = Yii::$app->getSecurity()->generateRandomString() . '_' . time();
|
||||
|
||||
return $fixture;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user