Commit a4d70f13 authored by Jérome Perrin's avatar Jérome Perrin

check the type of acl_users rather than the availability of...

check the type of acl_users rather than the availability of PluggableAuthService to decide wether we should allow duplicate reference

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6909 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cdab311e
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
############################################################################## ##############################################################################
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.ERP5.Core.Node import Node from Products.ERP5.Core.Node import Node
from Products.ERP5.Document.Entity import Entity from Products.ERP5.Document.Entity import Entity
...@@ -163,19 +164,21 @@ class Person(Entity, Node, XMLObject): ...@@ -163,19 +164,21 @@ class Person(Entity, Node, XMLObject):
PAS _AND_ ERP5UserManager are used PAS _AND_ ERP5UserManager are used
""" """
if value: if value:
if PluggableAuthService is not None: acl_users = getToolByName(self, 'acl_users')
plugin_list = self.acl_users.plugins.listPlugins( if PluggableAuthService is not None and isinstance(acl_users,
PluggableAuthService.PluggableAuthService.PluggableAuthService):
plugin_list = acl_users.plugins.listPlugins(
PluggableAuthService.interfaces.plugins.IUserEnumerationPlugin) PluggableAuthService.interfaces.plugins.IUserEnumerationPlugin)
for plugin_name, plugin_value in plugin_list: for plugin_name, plugin_value in plugin_list:
if isinstance(plugin_value, ERP5UserManager): if isinstance(plugin_value, ERP5UserManager):
user_list = self.acl_users.searchUsers(id = value, user_list = acl_users.searchUsers(id=value,
exact_match = True) exact_match=True)
if len(user_list) > 0: if len(user_list) > 0:
raise RuntimeError, 'user id %s already exist' % (value,) raise RuntimeError, 'user id %s already exist' % (value,)
break break
self._setReference(value) self._setReference(value)
self.reindexObject() self.reindexObject()
# invalid the cache for ERP5Security # invalid the cache for ERP5Security
clearCache() clearCache()
security.declareProtected(Permissions.SetOwnPassword, 'setPassword') security.declareProtected(Permissions.SetOwnPassword, 'setPassword')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment