Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public function onBeforeSetPassword(Event $event)
  2. {
  3. $user = $event->params['user'];
  4. $password = $event->params['password'];
  5.  
  6. if (mb_strlen($password) < 8)
  7. {
  8. $user->addError('password', 'Sorry but your password must be at least 8 characters.');
  9. $event->performAction = false;
  10. }
  11. if (!preg_match('/(d.*[A-Z]|[A-Z].*d)/', $password))
  12. {
  13. $user->addError('password', 'Sorry but your password must contain at least one uppercase letter and one number.');
  14. $event->performAction = false;
  15. }
  16. }
  17.  
  18. {% if account is defined and account.getErrors('password') %}
  19. {% include '_includes/formError' with { error : account.getErrors('password')|join('<br>') } %}
  20. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement