我使用 sfDoctrineGuardPlugin。密码更改的形式有三个字段:
当前密码、新密码、重复新密码。
如果当前是正确的,并且新的和重复的相同,我会这样做
$this->getUser()->getGuardUser()->setPassword($this->form->getValue('password'));
$this->getUser()->getGuardUser()->save();
在除 ie 之外的所有浏览器中,一切正常,但在 ie when save()
is - 或重新验证表单中,或重定向到相同的路由。
结果,用旧数据重新检查当前密码(然后有一个新密码),抛出表单错误。告诉我该怎么做,我不明白浏览器如何影响服务器操作。
public function executeChangePassword(sfWebRequest $request) {
$this->forward404Unless($this->getUser()->isAuthenticated());
$this->form = new ChangePasswordForm();
$this->bSuccess = false;
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$this->oUser = $this->getUser();
$this->oUser->setPassword($this->form->getValue('password'));
$this->bSuccess = true;
}
}
}
class ChangePasswordForm extends BaseForm {
public function configure() {
$this->setWidgets(array(
'current_password' => new sfWidgetFormInputPassword(array(), array('class' => 'b-input-text')),
'password' => new sfWidgetFormInputPassword(array(), array('class' => 'b-input-text')),
'password_again' => new sfWidgetFormInputPassword(array(), array('class' => 'b-input-text')),
));
$this->validatorSchema['current_password'] = new slValidatorUserPassword(
array('required' => true,
'min_length' => 6,
'max_length' => 128
)
);
$this->validatorSchema['password'] = new sfValidatorString(
array(
'required' => true,
'min_length' => 6,
'max_length' => 128
)
);
$this->validatorSchema['password_again'] = new sfValidatorString(
array('required' => true,
'min_length' => 6,
'max_length' => 128
)
);
$this-> mergePostValidator(new sfValidatorSchemaCompare('password', '==', 'password_again', array(), array()));
$this->widgetSchema->setNameFormat('change_password[%s]');
}
}