|
|
|
@ -2,7 +2,7 @@ from django.dispatch import receiver
@@ -2,7 +2,7 @@ from django.dispatch import receiver
|
|
|
|
|
from django.db.models.signals import post_save, post_delete, m2m_changed |
|
|
|
|
from django.contrib.auth import get_user_model |
|
|
|
|
from django.conf import settings |
|
|
|
|
from .ldap_sync import make_ldap_conn, LDAPAction, LDAPUserSyncer |
|
|
|
|
from .ldap_sync import make_ldap_conn, LDAPUserEntry, LDAPUserSyncer |
|
|
|
|
|
|
|
|
|
User = get_user_model() |
|
|
|
|
|
|
|
|
@ -25,7 +25,10 @@ def synchronous_user_sync(user, remove=False):
@@ -25,7 +25,10 @@ def synchronous_user_sync(user, remove=False):
|
|
|
|
|
ldap_conn.unbind_s() |
|
|
|
|
|
|
|
|
|
@receiver(post_save, sender=User) |
|
|
|
|
def handle_user_save(sender, instance, **kwargs): |
|
|
|
|
def handle_user_save(sender, instance, created, raw, using, update_fields, |
|
|
|
|
**kwargs): |
|
|
|
|
relevant_fields = LDAPUserEntry.get_mapped_fields() |
|
|
|
|
if update_fields is None or not update_fields.isdisjoint(relevant_fields): |
|
|
|
|
synchronous_user_sync(instance) |
|
|
|
|
|
|
|
|
|
@receiver(post_delete, sender=User) |
|
|
|
|