sfDoctrineGuardPlugin を使用しています。パスワード変更の形式には、次の 3 つのフィールドがあります。
現在のパスワード、新しいパスワード、新しいパスワードを繰り返します。
現在が正しく、新しいものと同じことが繰り返される場合、私はそうします
$this->getUser()->getGuardUser()->setPassword($this->form->getValue('password'));
$this->getUser()->getGuardUser()->save();
つまり、すべてのブラウザで問題ありませんが、つまり、save()
再検証フォーム、または同じルートにリダイレクトされます。
その結果、古いデータを使用して現在のパスワードの新しいチェックが行われ (その後、新しいパスワードが作成され)、フォームのエラーがスローされます。ブラウザーがサーバーの動作にどのように影響するかわかりません。
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]');
}
}