FOSUserBundleのパスワードの現在の検証を上書きしようとしています。いくつかのオプションを試しましたが、それでも解決策が見つかりません。
パスワードのMinLengthを増やすために、次のコマンドでvalidation.ymlを作成しました。
# src/Acme/UserBundle/Resources/config/validation.yml
Acme\UserBundle\Entity\User:
properties:
username:
- MinLength: { limit: 3, message: "Your username must have at least {{ limit }} characters." }
- MaxLength: { limit: 255, message: "The username is too long" }
- NotBlank: { message: "Please enter a username"}
plainPassword:
- NotBlank: { message: "Please enter a password"}
- MinLength: { limit: 8, message: "Your password must have at least {{ limit }} characters.", groups [Registration,Profile]}
- MaxLength: { limit: 255, message: "The password is too long" }
Acme\UserBundle\Form\Model\ChangePassword:
properties:
new:
- NotBlank: { message: "Please enter a new password", groups [ChangePassword]}
- MinLength: { limit: 8, message: "Your password must have at least {{ limit }} characters.", groups [ChangePassword]}
- MaxLength: { limit: 255, message: "The password is too long", groups [ChangePassword]}
Acme\UserBundle\Form\Model\ResetPassword:
new:
- NotBlank: { message: "Please enter a new password", groups [ResetPassword]}
- MinLength: { limit: 8, message: "Your new password must have at least {{ limit }} characters.", groups [ResetPassword]}
- MaxLength: { limit: 255, message: "The new password is too long", groups [ResetPassword]}
これは私にとっては問題なく機能しています/register
が/change-password
、デフォルトではFOSUserBundleからの最小長の検証が所有権を取得しています。
私の質問をより明確に述べるために、FOSUserBundleでパスワードのMinLengthを設定して、どこでも検証されるようにする正しい方法は何ですか?
さらに、ChangePassword内でそれを確認するためのFOSUserBundleの正しいアプローチは何oldpassword != newpassword
ですか?