[gen] Added method UserWrapper.addRole (add a role programmatically). Added to the LDAP config, a user map allowing to automatically assign roles and groups to ldap-imported users.

This commit is contained in:
Gaetan Delannay 2014-12-18 13:54:12 +01:00
parent 865e6bf08e
commit 982ae08997
2 changed files with 35 additions and 0 deletions

View file

@ -349,6 +349,15 @@ class UserWrapper(AbstractWrapper):
if role not in res: res.append(role)
return res
def addRole(self, role):
'''Adds p_role to the user's global roles.'''
roles = self.roles
if role in roles: return
roles = list(roles)
roles.append(role)
self.roles = roles
self.getZopeUser().roles = roles
def has_role(self, role, obj=None):
'''Has the logged user some p_role? If p_obj is None, check if the user
has p_role globally; else, check if he has this p_role in the context