Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:11:06+00:00 2026-05-28T11:11:06+00:00

I am attempting to create a change password form in cakephp 2.0. I found

  • 0

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.

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);
}

I am getting an error on the line that reads $this->Auth = new $auth();
The error is as follows:

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]

and

Undefined variable: collection [CORE\Cake\Controller\Component.php, line 78]

it’s also throwing this

Call to undefined method AuthComponent::verifyUser() in C:\UniServer\www\new_company_test\app\Model\Behavior\change_password.php on line 121 

I am not sure if there is anything else that needs to be addressed in the script, I’m guessing not as there is no other place where Auth is used.

Any suggestions on what I need to do to get this to work? Any help is appreciated.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:11:06+00:00Added an answer on May 28, 2026 at 11:11 am

    you did discover that there is also a 2.0 branch, didnt you? 🙂
    it should contain the same behavior:
    https://github.com/dereuromark/tools/tree/2.0

    either way, you need to pass a component collection into it:

    $this->Auth = new AuthExtComponent(new ComponentCollection());
    

    You should create a method verifyUser in your custom AuthExt Component which extends Auth Component for “current password” to work like so:

    /**
     * Quickfix
     * TODO: improve - maybe use Authenticate
     * @return bool $success
     */
    public function verifyUser($id, $pwd) {
        $options = array(
            'conditions' => array('id'=>$id, 'password'=>$this->password($pwd)),
        );
        return $this->getModel()->find('first', $options);
    
        $this->constructAuthenticate();
        $this->request->data['User']['password'] = $pwd;
        return $this->identify($this->request, $this->response);
    }
    
    /**
     * returns the current User model
     * @return object $User
     */
    public function getModel() {
        return ClassRegistry::init(CLASS_USER); 
    }
    

    Maybe it is also possible to use the existing identify method in combination with a fake request object in the behavior directly?
    I am thinking about using

    $this->authenticate = array('Form'=>array('fields'=>array('username' => 'id')));
    

    feel free to fork the behavior and submit a pull request.

    “current password” is the only thing that is not yet cleanly solved right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create my first WCF service. I've created the service and now
I am attempting to create a bookmarklet that will change the URL of the
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I am attempting to create a web page that will allow a user to
I am attempting to create an application that will initiate a call to a
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create a SVG Pie Graph that is 277 degrees. I
I am attempting to create functionality in a JSF1.2/ADF web app that will periodically
I'm attempting to create a custom JButton that has interchangeable skin components. Using CardLayout
I'm currently attempting to create a tabbed interface in a web application, and based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.