from Products.CMFDefault.exceptions import EmailAddressInvalid
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import getUtilityByInterfaceName
+from Products.CMFCore.utils import _checkPermission
from Products.CMFDefault.utils import checkEmailAddress
from Products.GroupUserFolder.GroupsToolPermissions import ManageGroups
from Products.Plinn.utils import Message as _
private_collections = portal.get('private_collections')
if not private_collections :
raise AccessControl_Unauthorized()
- return
+
data = private_collections.data
lines = filter(None, [l.strip() for l in data.split('\n')])
assert len(lines) % 3 == 0
if not (collecInfos.has_key(properties.get('collection_id')) and \
collecInfos[properties.get('collection_id')]['pw'] == properties.get('collection_password')) :
raise AccessControl_Unauthorized('Wrong primary credentials')
- return
BaseRegistrationTool.addMember(self, id, password, roles=roles,
BaseRegistrationTool.addMember(self, id, password, roles=roles,
domains=domains, properties=properties)
+ security.declarePublic( 'testPasswordValidity' )
+ def testPasswordValidity(self, password, confirm=None):
+
+ """ Verify that the password satisfies the portal's requirements.
+
+ o If the password is valid, return None.
+ o If not, return a string explaining why.
+ """
+ if not password:
+ return _(u'You must enter a password.')
+
+ if len(password) < 8 and not _checkPermission(ManagePortal, self):
+ return _(u'Your password must contain at least 8 characters.')
+
+ if confirm is not None and confirm != password:
+ return _(u'Your password and confirmation did not match. '
+ u'Please try again.')
+
+ return None
+
+
def afterAdd(self, member, id, password, properties):
""" notify member creation """
del self._passwordResetRequests[uuid]
return userid, _('Password successfully updated.')
else :
- return None, _('"%s" username not found.') % userid
+ return None, _('"${userid}" username not found.', mapping={'userid': userid})
else :
return None, msg