ignore errors because of missing principal; allow overwriting password when principal exists
This commit is contained in:
parent
f03f11372e
commit
1f681de414
2 changed files with 13 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue