Skip to content

Commit

Permalink
Put 5 char password policy into a PAS plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
djay committed Dec 19, 2011
1 parent 15f2fd2 commit 5966fa4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Products/PlonePAS/plugins/property.py
Expand Up @@ -14,10 +14,14 @@
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
from Products.PluggableAuthService.interfaces.plugins import IPropertiesPlugin
from Products.PluggableAuthService.interfaces.plugins import IUserEnumerationPlugin
from Products.PluggableAuthService.interfaces.plugins import IValidationPlugin
from Products.PluggableAuthService.UserPropertySheet import _guessSchema
from Products.PlonePAS.sheet import MutablePropertySheet, validateValue
from Products.PlonePAS.interfaces.plugins import IMutablePropertiesPlugin
from Products.PlonePAS.utils import safe_unicode
from zope.i18nmessageid import MessageFactory

This comment has been minimized.

Copy link
@mitchellrj

mitchellrj Apr 26, 2012

No need to import/create this message factory any more, since its usage was removed by 3352ecb

_ = MessageFactory('plone')


def manage_addZODBMutablePropertyProvider(self, id, title='',
Expand Down Expand Up @@ -48,7 +52,7 @@ class ZODBMutablePropertyProvider(BasePlugin):
meta_type = 'ZODB Mutable Property Provider'

implements(IPropertiesPlugin, IUserEnumerationPlugin,
IMutablePropertiesPlugin)
IMutablePropertiesPlugin, IValidationPlugin)

security = ClassSecurityInfo()

Expand Down Expand Up @@ -265,6 +269,24 @@ def enumerateUsers( self

return tuple(user_info)

security.declarePrivate('validateUserInfo')
def validateUserInfo(self, user, set_id, set_info ):
""" See IValidationPlugin. Used to validate password property
"""

errors = []

if set_info and set_info.get('password', None) is not None:
password = set_info['password']
if not password:
errors = [{'id':'password','error':_(u'Minimum 5 characters.')}]
return []
elif len(password) < 5:
errors = [{'id':'password','error':
_(u'Your password must contain at least 5 characters.')}]
else:
errors = []
return errors

InitializeClass(ZODBMutablePropertyProvider)

Expand Down

0 comments on commit 5966fa4

Please sign in to comment.