avoid prindipal IDs with special characters, skipping existing ones if necessary
This commit is contained in:
parent
1800fe7c9e
commit
3990b710c6
4 changed files with 22 additions and 6 deletions
Binary file not shown.
|
@ -3,7 +3,7 @@ msgstr ""
|
||||||
|
|
||||||
"Project-Id-Version: 0.13.1\n"
|
"Project-Id-Version: 0.13.1\n"
|
||||||
"POT-Creation-Date: 2007-05-22 12:00 CET\n"
|
"POT-Creation-Date: 2007-05-22 12:00 CET\n"
|
||||||
"PO-Revision-Date: 2015-09-22 12:00 CET\n"
|
"PO-Revision-Date: 2015-10-25 12:00 CET\n"
|
||||||
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
|
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
|
||||||
"Language-Team: loops developers <helmutm@cy55.de>\n"
|
"Language-Team: loops developers <helmutm@cy55.de>\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -855,6 +855,9 @@ msgstr "Benutzer registrieren"
|
||||||
msgid "Register new member"
|
msgid "Register new member"
|
||||||
msgstr "Neu registrieren"
|
msgstr "Neu registrieren"
|
||||||
|
|
||||||
|
msgid "Login name not allowed."
|
||||||
|
msgstr "Die von Ihnen eingegebene Benutzerkennung enthält Sonderzeichen, z. B. Umlaute."
|
||||||
|
|
||||||
msgid "Login name already taken."
|
msgid "Login name already taken."
|
||||||
msgstr "Die von Ihnen eingegebene Benutzerkennung ist schon vergeben."
|
msgstr "Die von Ihnen eingegebene Benutzerkennung ist schon vergeben."
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2014 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -91,6 +91,7 @@ class BaseMemberRegistration(NodeView):
|
||||||
formErrors = dict(
|
formErrors = dict(
|
||||||
confirm_nomatch=FormError(_(u'Password and password confirmation '
|
confirm_nomatch=FormError(_(u'Password and password confirmation '
|
||||||
u'do not match.')),
|
u'do not match.')),
|
||||||
|
illegal_loginname=FormError(_('Login name not allowed.')),
|
||||||
duplicate_loginname=FormError(_('Login name already taken.')),
|
duplicate_loginname=FormError(_('Login name already taken.')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -79,8 +79,10 @@ class MemberRegistrationManager(object):
|
||||||
if pfName is None:
|
if pfName is None:
|
||||||
pfName = options(self.principalfolder_key,
|
pfName = options(self.principalfolder_key,
|
||||||
(self.default_principalfolder,))[0]
|
(self.default_principalfolder,))[0]
|
||||||
self.createPrincipal(pfName, userId, password, lastName, firstName,
|
rc = self.createPrincipal(pfName, userId, password,
|
||||||
useExisting=useExisting)
|
lastName, firstName, useExisting=useExisting)
|
||||||
|
if rc is not None:
|
||||||
|
return rc
|
||||||
if not groups:
|
if not groups:
|
||||||
groups = options(self.groups_key, ())
|
groups = options(self.groups_key, ())
|
||||||
self.setGroupsForPrincipal(pfName, userId, groups=groups)
|
self.setGroupsForPrincipal(pfName, userId, groups=groups)
|
||||||
|
@ -90,6 +92,8 @@ class MemberRegistrationManager(object):
|
||||||
def createPrincipal(self, pfName, userId, password, lastName,
|
def createPrincipal(self, pfName, userId, password, lastName,
|
||||||
firstName=u'', groups=[], useExisting=False,
|
firstName=u'', groups=[], useExisting=False,
|
||||||
overwrite=False, **kw):
|
overwrite=False, **kw):
|
||||||
|
if not self.checkPrincipalId(userId):
|
||||||
|
return dict(fieldName='loginName', error='illegal_loginname')
|
||||||
pFolder = getPrincipalFolder(self.context, pfName)
|
pFolder = getPrincipalFolder(self.context, pfName)
|
||||||
if IPersonBasedAuthenticator.providedBy(pFolder):
|
if IPersonBasedAuthenticator.providedBy(pFolder):
|
||||||
pFolder.setPassword(userId, password)
|
pFolder.setPassword(userId, password)
|
||||||
|
@ -123,10 +127,18 @@ class MemberRegistrationManager(object):
|
||||||
if gFolder is not None:
|
if gFolder is not None:
|
||||||
group = gFolder.get(gName)
|
group = gFolder.get(gName)
|
||||||
if group is not None:
|
if group is not None:
|
||||||
members = list(group.principals)
|
members = [p for p in group.principals
|
||||||
|
if self.checkPrincipalId(p)]
|
||||||
members.append(pFolder.prefix + userId)
|
members.append(pFolder.prefix + userId)
|
||||||
group.principals = members
|
group.principals = members
|
||||||
|
|
||||||
|
def checkPrincipalId(self, pid):
|
||||||
|
try:
|
||||||
|
pid = str(pid)
|
||||||
|
return True
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return False
|
||||||
|
|
||||||
def createPersonForPrincipal(self, pfName, userId, lastName, firstName=u'',
|
def createPersonForPrincipal(self, pfName, userId, lastName, firstName=u'',
|
||||||
useExisting=False, **kw):
|
useExisting=False, **kw):
|
||||||
concepts = self.context.getConceptManager()
|
concepts = self.context.getConceptManager()
|
||||||
|
|
Loading…
Add table
Reference in a new issue