mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Update service groups as they're added to the user, avoiding another costly cronjob
This commit is contained in:
@@ -107,13 +107,13 @@ class SSOUser(models.Model):
|
||||
profile, created = SSOUser.objects.get_or_create(user=instance)
|
||||
|
||||
@staticmethod
|
||||
def update_service_groups(sender, instance, created, **kwargs):
|
||||
if not created:
|
||||
def update_service_groups(sender, instance, action, **kwargs):
|
||||
if action in ['post_add', 'post_remove']:
|
||||
for acc in instance.serviceaccount_set.all():
|
||||
acc.service.api_class.update_groups(acc.service_uid, instance.groups.all())
|
||||
|
||||
signals.post_save.connect(SSOUser.create_user_profile, sender=User)
|
||||
#signals.post_save.connect(SSOUser.update_service_groups, sender=User)
|
||||
signals.m2m_changed.connect(SSOUser.update_service_groups, sender=User.groups.through)
|
||||
|
||||
class SSOUserNote(models.Model):
|
||||
""" Notes bound to a user's account. Used to store information regarding the user """
|
||||
|
||||
Reference in New Issue
Block a user