Commit 39bfe1dc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

erp5_base: user getUserValue() and getLoginValueList() in ERP5UserFactory.

parent 32aa838d
...@@ -3,9 +3,10 @@ Returns None if no corresponding person, for example when not using ERP5Security ...@@ -3,9 +3,10 @@ Returns None if no corresponding person, for example when not using ERP5Security
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
if user_name is None: if user_name is None:
user_name = portal.portal_membership.getAuthenticatedMember() return portal.portal_membership.getAuthenticatedMember().getUser().getUserValue()
user_list = [x for x in portal.acl_users.searchUsers(
from Products.ERP5Security.ERP5UserManager import getUserByLogin exact_match=True,
found_user_list = getUserByLogin(portal, str(user_name)) id=user_name,
if len(found_user_list) == 1: ) if 'path' in x]
return found_user_list[0] if len(user_list) == 1:
return portal.restrictedTraverse(user_list[0]['path'])
...@@ -3,8 +3,7 @@ from Products.ERP5Type.Message import translateString ...@@ -3,8 +3,7 @@ from Products.ERP5Type.Message import translateString
portal = context.getPortalObject() portal = context.getPortalObject()
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
person = portal.restrictedTraverse(portal.acl_users.erp5_users.enumerateUsers(id=user.getId())[0]['path']) for login in user.getLoginValueList(portal_type='ERP5 Login'):
for login in person.objectValues(portal_type='ERP5 Login'):
if login.getReference() == reference and login.getValidationState() == 'validated': if login.getReference() == reference and login.getValidationState() == 'validated':
break break
else: else:
......
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