Password hash implementation

I am developing a new application using Symfony. I want to save hashed passwords, so I redefined the save method in my User model:

public function save(Doctrine_Connection $conn = null)
{
    $this->setUserPassword( md5($this->getUserPassword()) );
return parent::save($conn);
}

This works well when creating a new user. However, this causes problems when editing the user without changing his password. This forces Doctrine to hash the password already hashed.

So, I need to check if UserPassword is being changed in the DoctrineRecord instance. How can i do this?

+3
source share
1 answer

Solution: We only need to override the setter method:

public function setUserPassword($password)
{
    return $this->_set('user_password', md5($password));
}
+8
source

Source: https://habr.com/ru/post/1745521/


All Articles