Fortuna
Fortuna

Reputation: 19

CakePHP 2.0 AuthComponent hashes passwords automatically

Im currently working with the new version of our lovely framework. Now where I work on the registration the AuthComponent hashes my password automatically, although the manual explicit says that this has been removed in the new version. So is this a core bug or did I something wrong? There nothing special in my code, I just have two fields password and *confirm_password* which I compare in my validation. But since CakePHP hashes password I had to write something like this:

public function checkPasswords($data) {
        $data = array_keys($data);
        return $this->data['User'][$data[0]] === AuthComponent::password($this->data['User']['confirm_password']);
    }

The main problem occures when I try to login, there the password field isnt hashed automatically. Can someone help me? I dont know why AuthComponent hashes the password at my "register" function and doesnt in my "login" function?

Upvotes: 0

Views: 1814

Answers (1)

Scott Harwell
Scott Harwell

Reputation: 7465

Sounds like you are using a different version of CakePHP. Version 2.0+ definitely does not hash the passwords without you coding it explicitly; so you are using 1.x or you have hashed the passwords elsewhere in your code. Are you sure that the method that passes $data to checkPasswords() has not done the hashing?

Show us the register() function to allow better understanding of the issue.

Upvotes: 1

Related Questions