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):
user = user_list[0]
if user.getPassword() == password:
if user.getPassword() == password and\
user.getCareerRole() == 'internal':
LOG('authenticateCredentials', 0, user.getId())
return user.getId(), login
return login, login # use same for user_id and login
return None
......@@ -94,31 +95,20 @@ class ERP5UserManager(BasePlugin):
def enumerateUsers(self, id=None, login=None, exact_match=False, sort_by=None, max_results=None, **kw):
""" See IUserEnumerationPlugin.
"""
def _enumerateUsers(t_id, path):
def _enumerateUsers(id_tuple, exact_match, path):
user_info = []
user_objects = []
plugin_id = self.getId()
if isinstance(t_id, str):
t_id = (t_id,)
if not exact_match:
id_tuple = tuple(['%%%s%%' % id for id in id_tuple])
if t_id:
person_module = self.getPortalObject()\
.getDefaultModule('Person')
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)
user_objects = [user for user in self.getUserByLogin(id_tuple)\
if user.getCareerRole() == 'internal']
#XXX is this static check ok ?
for user in user_objects:
LOG('enumerateUsers', 0, user.getId())
info = { 'id' : user.getId()
LOG('enumerateUsers', 0, user.getReference())
info = { 'id' : user.getReference()
, 'login' : user.getReference()
, 'pluginid' : plugin_id
}
......@@ -129,9 +119,11 @@ class ERP5UserManager(BasePlugin):
_enumerateUsers = CachingMethod(_enumerateUsers, id='ERP5UserManager_enumerateUsers')
if isinstance(id, str):
id = (id,)
if isinstance(id, list):
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):
"""
......
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