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,6 +476,9 @@ class IndexAttributes(object):
|
||||||
for c in cr:
|
for c in cr:
|
||||||
try:
|
try:
|
||||||
principal = pau.getPrincipal(c)
|
principal = pau.getPrincipal(c)
|
||||||
|
if principal is None:
|
||||||
|
creators.append(c)
|
||||||
|
else:
|
||||||
creators.append(principal.title)
|
creators.append(principal.title)
|
||||||
except PrincipalLookupError:
|
except PrincipalLookupError:
|
||||||
creators.append(c)
|
creators.append(c)
|
||||||
|
|
|
@ -78,14 +78,21 @@ class MemberRegistrationManager(object):
|
||||||
useExisting, **kw)
|
useExisting, **kw)
|
||||||
|
|
||||||
def createPrincipal(self, pfName, userId, password, lastName,
|
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)
|
pFolder = getPrincipalFolder(self.context, pfName)
|
||||||
if IPersonBasedAuthenticator.providedBy(pFolder):
|
if IPersonBasedAuthenticator.providedBy(pFolder):
|
||||||
pFolder.setPassword(userId, password)
|
pFolder.setPassword(userId, password)
|
||||||
else:
|
else:
|
||||||
title = firstName and ' '.join((firstName, lastName)) or lastName
|
title = firstName and ' '.join((firstName, lastName)) or lastName
|
||||||
principal = InternalPrincipal(userId, password, title)
|
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:
|
if userId not in pFolder:
|
||||||
pFolder[userId] = principal
|
pFolder[userId] = principal
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue