Ignore:
Timestamp:
19 Nov 2011, 23:03:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement PasswordValidator? global utility as suggested by Uli.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/authentication.py

    r7137 r7147  
    99from zope.securitypolicy.interfaces import IPrincipalRoleManager
    1010from zope.securitypolicy.principalrole import principalRoleManager
    11 from waeup.sirp.interfaces import IUserAccount, IAuthPluginUtility
     11from waeup.sirp.interfaces import (
     12    IUserAccount, IAuthPluginUtility, IPasswordValidator)
    1213
    1314def setup_authentication(pau):
     
    170171        site = grok.getSite()
    171172        return site['users']
     173
     174class PasswordValidator(grok.GlobalUtility):
     175
     176  grok.implements(IPasswordValidator)
     177
     178  def validate_password(self, pw, pw_repeat):
     179       errors = []
     180       if len(pw) < 3:
     181         errors.append('Password must have at least 3 chars.')
     182       if pw != pw_repeat:
     183         errors.append('Passwords do not match.')
     184       return errors
    172185
    173186@grok.subscribe(IUserAccount, grok.IObjectRemovedEvent)
Note: See TracChangeset for help on using the changeset viewer.