Hash of some Cakephp2 field

Asked

Viewed 26 times

-1

I generated some scaffolding tables from Cakephp2, I have a model called account and created a Setter and getter:

public function setPassword($password)
{
    $this->password = Security::encrypt($password);
}

public function getpassword()
{
    return Security::encrypt($this->password);
}

Only scaffolding doesn’t use these methods. How do I hash the field both in the insertion and in the view?

1 answer

0

I suggested you use the beforeSave to change the values before they are saved, and then you can do Security::encrypt() the password.

As I recall, Cakephp2 doesn’t use getters/setters that way.

Why do you need to do it again encrypt preview? You will already have the encrypted value after doing the find, however, you can use the afterFind after the query, change the data as needed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.