ignore errors because of missing principal; allow overwriting password when principal exists

This commit is contained in:
Helmut Merz 2012-03-05 12:25:02 +01:00
parent f03f11372e
commit 1f681de414
2 changed files with 13 additions and 3 deletions

View file

@ -476,7 +476,10 @@ class IndexAttributes(object):
for c in cr:
try:
principal = pau.getPrincipal(c)
creators.append(principal.title)
if principal is None:
creators.append(c)
else:
creators.append(principal.title)
except PrincipalLookupError:
creators.append(c)
return creators

View file

@ -78,14 +78,21 @@ class MemberRegistrationManager(object):
useExisting, **kw)
def createPrincipal(self, pfName, userId, password, lastName,
firstName=u'', groups=[], useExisting=False, **kw):
firstName=u'', groups=[], useExisting=False,
overwrite=False, **kw):
pFolder = getPrincipalFolder(self.context, pfName)
if IPersonBasedAuthenticator.providedBy(pFolder):
pFolder.setPassword(userId, password)
else:
title = firstName and ' '.join((firstName, lastName)) or lastName
principal = InternalPrincipal(userId, password, title)
if useExisting:
if overwrite:
if userId in pFolder:
principal = pFolder[userId]
principal.password = password
else:
pFolder[userId] = principal
elif useExisting:
if userId not in pFolder:
pFolder[userId] = principal
else: