找不到current_password的验证处理程序checkCurrentPassword

时间:2016-07-07 12:04:21

标签: php validation cakephp passwords cakephp-2.0

我收到这样的错误

  

警告(512):找不到验证处理程序checkCurrentPassword   for current_password   [CORE / Cake / Model / Validator / CakeValidationRule.php,第281行]

我的User.php

public function validate_passwords() {
        return check( $this->data[$this->alias]['confirm_password'], $this->data[$this->alias]['password']);
}

2 个答案:

答案 0 :(得分:0)

你不能像这样访问check(),因为它是受保护的方法

有关详细信息,请参阅:http://api.cakephp.org/3.0/class-Cake.Validation.Validation.html

不要尝试下面的内容:

public function validate_passwords() {
    return array('check' => array($this->data[$this->alias]['confirm_password'], $this->data[$this->alias]['password']));

}

要使用密码验证confirm_password,请添加以下规则:

$validator->add('confirm_password', 'no-misspelling', [
    'rule' => ['compareWith', 'password'],
    'message' => 'Passwords are not equal',
]);

答案 1 :(得分:0)

您可以使用此密码

验证confirm_password
$(document).ready (function(){
    // run all your functions here
});

为你工作。