frontend\models\ChangePasswordForm::validatePassword PHP Method

validatePassword() public method

This method serves as the inline validation for password.
public validatePassword ( string $attribute, array $params )
$attribute string the attribute currently being validated
$params array the additional name-value pairs given in the rule
    public function validatePassword($attribute, $params)
    {
        if (!$this->hasErrors()) {
            $user = Yii::$app->user->identity;
            if ($user->validatePassword($this->password)) {
                $this->addError($attribute, '新密码不可与当前密码相同。');
            }
        }
    }