我正在尝试在cakephp 2.0中创建更改密码表单。我发现了EuroMark为1.3创建的行为,现在我很难将这段代码转换为2.0。我知道它与Auth Component有关,因为在2.0中这个组件发生了重大变化。Cakephp 2.0更改密码
public function validateCurrentPwd(Model $Model, $data) {
if (is_array($data)) {
$pwd = array_shift($data);
} else {
$pwd = $data;
}
$uid = null;
if ($Model->id) {
$uid = $Model->id;
} elseif (!empty($Model->data[$Model->alias]['id'])) {
$uid = $Model->data[$Model->alias]['id'];
} else {
return false;
}
if (class_exists('AuthExtComponent')) {
$this->Auth = new AuthExtComponent();
} elseif (class_exists($this->settings[$Model->alias]['auth'].'Component')) {
$auth = $this->settings[$Model->alias]['auth'].'Component';
$this->Auth = new $auth();
} else {
return true;
}
return $this->Auth->verifyUser($uid, $pwd);
}
我在读取$ this-> Auth = new $ auth();的行时出错。 错误如下:
Argument 1 passed to Component::__construct() must be an instance of ComponentCollection, none given, called in C:\UniServer\www\new_company_test\app\Model\Behavior\change_password.php on line 117 and defined [CORE\Cake\Controller\Component.php, line 77]
和
Undefined variable: collection [CORE\Cake\Controller\Component.php, line 78]
它也引发此
Call to undefined method AuthComponent::verifyUser() in C:\UniServer\www\new_company_test\app\Model\Behavior\change_password.php on line 121
我不知道是否有其他任何需要在脚本中予以解决,我猜测没有其他地方使用Auth。
关于我需要做什么才能使其发挥作用的任何建议?任何帮助表示赞赏。 谢谢
我目前的工作是对“当前密码”功能进行干净的2.0重写(必须是1.3的相当黑客)。将在我完成后立即发布。 – mark