New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overwrite minimum password lenght #987
Comments
You have to extend namespace Acme\Bundle\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeUserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
} Now. In the <?xml version="1.0" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="FOS\UserBundle\Model\User">
<property name="plainPassword">
<constraint name="NotBlank">
<option name="message">fos_user.password.blank</option>
<option name="groups">
<value>Registration</value>
<value>ResetPassword</value>
<value>ChangePassword</value>
</option>
</constraint>
<constraint name="Length">
<option name="min">6</option> <!-- !!! change password length here !!! -->
<option name="minMessage">fos_user.password.short</option>
<option name="groups">
<value>Registration</value>
<value>Profile</value>
<value>ResetPassword</value>
<value>ChangePassword</value>
</option>
</constraint>
</property>
</class>
</constraint-mapping> You can also use yml for validation's rules. *Read more about bundle inheritance here: |
Hi Sharom, how can I replace the rules and not merge them with the validation.xml from parent bundle? |
Hi @kieste. I am not sure that it is exclusive solution. In this way you may write clean validation's constraints for you entity. |
Thats one way but it will not work as the https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Security/UserProvider.php#L59 has a hard requirement for the User object. |
how to do this in validation.yml ? |
@gondo, Something like this will do it:
|
@lancergr nope, tried exactly that and for some reason it was ignored. i even tried it with |
Hi , I am using FOS bundle in my project. I create a new controller ChangePasswordControlle in my admin bundle. Here is my code. namespace Pondip\AdminBundle\Controller; use Symfony\Component\HttpFoundation\Request; /**
} Now i want to customize error message for current password. So please help me urgent. |
for symfony 4 https://symfony.com/doc/current/bundles/override.html |
How do I overwrite minimum passoword lenght in registration and set even some password requirements?
The text was updated successfully, but these errors were encountered: