{"id":3113,"date":"2014-03-16T20:28:55","date_gmt":"2014-03-16T20:28:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/cakephp-2-0-change-password-collection-of-common-programming-errors\/"},"modified":"2014-03-16T20:28:55","modified_gmt":"2014-03-16T20:28:55","slug":"cakephp-2-0-change-password-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/cakephp-2-0-change-password-collection-of-common-programming-errors\/","title":{"rendered":"Cakephp 2.0 change password-Collection of common programming errors"},"content":{"rendered":"<p>I am attempting to create a change password form in cakephp 2.0. I found a behavior that EuroMark created for 1.3 and now am having a tough time converting this code to work with 2.0. I know that it has something to do with the Auth Component as there were major changes to this component in 2.0.<\/p>\n<pre><code>public function validateCurrentPwd(Model $Model, $data) {\nif (is_array($data)) {\n    $pwd = array_shift($data);\n} else {\n    $pwd = $data;\n}\n\n$uid = null;\nif ($Model-&gt;id) {\n    $uid = $Model-&gt;id;\n} elseif (!empty($Model-&gt;data[$Model-&gt;alias]['id'])) {\n    $uid = $Model-&gt;data[$Model-&gt;alias]['id'];\n} else {\n    return false;\n}\n\nif (class_exists('AuthExtComponent')) {\n    $this-&gt;Auth = new AuthExtComponent();\n} elseif (class_exists($this-&gt;settings[$Model-&gt;alias]['auth'].'Component')) {\n    $auth = $this-&gt;settings[$Model-&gt;alias]['auth'].'Component';\n    $this-&gt;Auth = new $auth();\n} else {\n    return true;\n}\nreturn $this-&gt;Auth-&gt;verifyUser($uid, $pwd);\n}\n<\/code><\/pre>\n<p>I am getting an error on the line that reads $this-&gt;Auth = new $auth(); The error is as follows:<\/p>\n<pre><code>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]\n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>Undefined variable: collection [CORE\\Cake\\Controller\\Component.php, line 78]\n<\/code><\/pre>\n<p>it&#8217;s also throwing this<\/p>\n<pre><code>Call to undefined method AuthComponent::verifyUser() in C:\\UniServer\\www\\new_company_test\\app\\Model\\Behavior\\change_password.php on line 121 \n<\/code><\/pre>\n<p>I am not sure if there is anything else that needs to be addressed in the script, I&#8217;m guessing not as there is no other place where Auth is used.<\/p>\n<p>Any suggestions on what I need to do to get this to work? Any help is appreciated. Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am attempting to create a change password form in cakephp 2.0. I found a behavior that EuroMark created for 1.3 and now am having a tough time converting this code to work with 2.0. I know that it has something to do with the Auth Component as there were major changes to this component [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3113","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3113"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3113\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}