Commit f78b0e95 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Replaced all references to Person.id by Person.reference, like in

ERP5GroupManager. cleaned a bit.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5087 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c94e6d2f
...@@ -78,9 +78,10 @@ class ERP5UserManager(BasePlugin): ...@@ -78,9 +78,10 @@ class ERP5UserManager(BasePlugin):
user = user_list[0] user = user_list[0]
if user.getPassword() == password: if user.getPassword() == password and\
user.getCareerRole() == 'internal':
LOG('authenticateCredentials', 0, user.getId()) LOG('authenticateCredentials', 0, user.getId())
return user.getId(), login return login, login # use same for user_id and login
return None return None
...@@ -94,31 +95,20 @@ class ERP5UserManager(BasePlugin): ...@@ -94,31 +95,20 @@ class ERP5UserManager(BasePlugin):
def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw): def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw):
""" See IUserEnumerationPlugin. """ See IUserEnumerationPlugin.
""" """
def _enumerateUsers(t_id, path): def _enumerateUsers(id_tuple, exact_match, path):
user_info = [] user_info = []
user_objects = []
plugin_id = self.getId() plugin_id = self.getId()
if isinstance(t_id, str): if not exact_match:
t_id = (t_id,) id_tuple = tuple(['%%%s%%' % id for id in id_tuple])
if t_id: user_objects = [user for user in self.getUserByLogin(id_tuple)\
person_module = self.getPortalObject()\ if user.getCareerRole() == 'internal']
.getDefaultModule('Person') #XXX is this static check ok ?
for user_name in t_id:
user = getattr(person_module, user_name, None)
if user:
if user.getCareerRole() == 'internal':
user_objects.append(user)
elif login:
for user in self.getUserByLogin(login):
if user.getCareerRole() == 'internal':
user_objects.append(user)
for user in user_objects: for user in user_objects:
LOG('enumerateUsers', 0, user.getId()) LOG('enumerateUsers', 0, user.getReference())
info = { 'id' : user.getId() info = { 'id' : user.getReference()
, 'login' : user.getReference() , 'login' : user.getReference()
, 'pluginid' : plugin_id , 'pluginid' : plugin_id
} }
...@@ -129,9 +119,11 @@ class ERP5UserManager(BasePlugin): ...@@ -129,9 +119,11 @@ class ERP5UserManager(BasePlugin):
_enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers') _enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers')
if isinstance(id, str):
id = (id,)
if isinstance(id, list): if isinstance(id, list):
id = tuple(id) id = tuple(id)
return _enumerateUsers(t_id=id, path=self.getPhysicalPath()) return _enumerateUsers(id_tuple=id, exact_match=exact_match, path=self.getPhysicalPath())
def getUserByLogin(self, login): def getUserByLogin(self, login):
""" """
......
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