3

I am developing a new application using Symfony. I want to store the passwords hashed, so I overridded 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 good when a new user created. However, this causes problems when we edit a user without changing his password. This causes Doctrine to hash the already hashed password.

So, I need to check that whether the UserPassword is modified in this DoctrineRecord instance. How can I manage to do that?

1 Answer 1

8

Solution: We need to override the setter method only:

public function setUserPassword($password)
{
    return $this->_set('user_password', md5($password));
}
Sign up to request clarification or add additional context in comments.

1 Comment

Damn, 3rd question I look where the OP answered himself before anyone. I guess SO's gonna die soon, people became too smart !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.