source: trunk/skins/lemill/validate_user.vpy @ 1223

Revision 1223, 848 bytes checked in by laszlo, 13 years ago (diff)

closed #1027 spent 6h

Line 
1## Controlled Python Script "validate_emailaddr"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters=username=''
9##title=Validates user name
10##
11
12from Products.CMFPlone import PloneMessageFactory as _
13from Products.CMFCore.utils import getToolByName
14
15reg_tool=context.portal_registration
16
17def invalid(field):
18    state.setError(field, _(u'This user name is alredy in use.'), 'existing_user')
19
20mtool = context.portal_membership
21for id in mtool.listMemberIds():
22    if username and cmp(username.lower(), id.lower())==0:
23        invalid('username')
24       
25if state.getErrors():
26    context.plone_utils.addPortalMessage(_(u'Please correct the indicated errors.'))
27    return state.set(status='failure')
28else:
29    return state
Note: See TracBrowser for help on using the repository browser.