Doctrine password hash after regexp validate
I have a problem during save password on database. I have password field with complex regexp validator (minlenght + special chars + alphanumerics). After send form, password value is checked by validator. After that (if value is valid) I would like hash password and finally save this value, but regexp validator still validate field and return error.
How can i disable validator before finally save ha开发者_开发技巧shed value?
Sorry for my english!
Code:
On user model:
public function setTableDefinition()
{
$this->hasColumn('password', 'string', 32, array ('notnull'=>true, 'minlength'=>8, 'regexp'=> '/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/'));
.......
}
public function setUp()
{
$this->addListener(new userChangeListener());
}
On listener:
class userChangeListener extends Doctrine_Record_Listener
{
public function postValidate(Doctrine_Event $event)
{
$invoker = $event->getInvoker();
$invoker->password = md5($invoker->password);
}
}
精彩评论