mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
LDAP: refresh group when edit user (Fix #62)
This commit is contained in:
parent
1bb1c9f490
commit
4c42f72f98
1 changed files with 6 additions and 2 deletions
|
@ -568,7 +568,7 @@ class User(AbstractBaseUser):
|
||||||
return
|
return
|
||||||
user_right.delete()
|
user_right.delete()
|
||||||
|
|
||||||
def ldap_sync(self, base=True, access_refresh=True, mac_refresh=True):
|
def ldap_sync(self, base=True, access_refresh=True, mac_refresh=True, group_refresh=False):
|
||||||
""" Synchronisation du ldap. Synchronise dans le ldap les attributs de
|
""" Synchronisation du ldap. Synchronise dans le ldap les attributs de
|
||||||
self
|
self
|
||||||
Options : base : synchronise tous les attributs de base - nom, prenom,
|
Options : base : synchronise tous les attributs de base - nom, prenom,
|
||||||
|
@ -576,6 +576,7 @@ class User(AbstractBaseUser):
|
||||||
access_refresh : synchronise le dialup_access notant si l'user a accès
|
access_refresh : synchronise le dialup_access notant si l'user a accès
|
||||||
aux services
|
aux services
|
||||||
mac_refresh : synchronise les machines de l'user
|
mac_refresh : synchronise les machines de l'user
|
||||||
|
group_refresh : synchronise les group de l'user
|
||||||
Si l'instance n'existe pas, on crée le ldapuser correspondant"""
|
Si l'instance n'existe pas, on crée le ldapuser correspondant"""
|
||||||
self.refresh_from_db()
|
self.refresh_from_db()
|
||||||
try:
|
try:
|
||||||
|
@ -608,6 +609,9 @@ class User(AbstractBaseUser):
|
||||||
user_ldap.macs = [str(mac) for mac in Interface.objects.filter(
|
user_ldap.macs = [str(mac) for mac in Interface.objects.filter(
|
||||||
machine__user=self
|
machine__user=self
|
||||||
).values_list('mac_address', flat=True).distinct()]
|
).values_list('mac_address', flat=True).distinct()]
|
||||||
|
if group_refresh:
|
||||||
|
for right in Right.objects.filter(user=self):
|
||||||
|
right.right.ldap_sync()
|
||||||
user_ldap.save()
|
user_ldap.save()
|
||||||
|
|
||||||
def ldap_del(self):
|
def ldap_del(self):
|
||||||
|
@ -829,7 +833,7 @@ def user_post_save(sender, **kwargs):
|
||||||
user = kwargs['instance']
|
user = kwargs['instance']
|
||||||
if is_created:
|
if is_created:
|
||||||
user.notif_inscription()
|
user.notif_inscription()
|
||||||
user.ldap_sync(base=True, access_refresh=True, mac_refresh=False)
|
user.ldap_sync(base=True, access_refresh=True, mac_refresh=False, group_refresh=True)
|
||||||
regen('mailing')
|
regen('mailing')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue