Sto tentando di ignorare la convalida corrente per le password in FOSUserBundle. Ho provato alcune opzioni, ma non riesco ancora a trovare la soluzione.Convalida password FOSUserBundle
Per aumentare minLength della parola, ho creato un validation.yml con:
# 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]}
Questo sta lavorando per me bene sul /register
, ma sul /change-password
il default min convalida lunghezza da FOSUserBundle sta prendendo possesso.
Per specificare più chiaramente la mia domanda, qual è il modo corretto per impostare la lunghezza minima della password in FOSUserBundle per assicurarsi che sia convalidata ovunque?
Inoltre, qual è l'approccio corretto con FOSUserBundle per verificare all'interno di ChangePassword che oldpassword != newpassword
?
Questo è qualcosa che ho rimosso, nel tentativo di vedere se quella era la causa dei miei problemi. Li ho rimessi qui per verificare, sembra che non facciano alcuna differenza. Modificare qui sopra per includerli nuovamente per maggiore chiarezza. – MadManMonty