We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Do not change the password

Hi,

I have a problem about the password when I insert it into the database. I don't want to change the user's password if it's an update and if this password is null but if it's not null I want to insert it. I think I have to put this code in the function's model (BeforeValidationOnUpdate) but how I can assign the same password's value to validate the sha1 password ?



41.3k
Accepted
answer

Problem solved in this Thread.



51.2k

I had similar problems. See https://forum.phalcon.io/discussion/863/skip-columns-on-validation-process . Unfortunately I ended up in creating a sepparately "change password form" that is handling this.

The best thing would be if they will add a skipColumn method. For now you can do that but onli on initialize(). The perfect way would be to have something like this:

public function beforeValidationOnUpdate()
{
    if (strlen($this->password) > 1) {
        $this->skipAttributes(
            array(
                'password'
            )
        );  
    }
}

+1 for this !