Skip to content

Commit

Permalink
feat: add signal to move new users to "editors" group
Browse files Browse the repository at this point in the history
  • Loading branch information
sennierer authored and gythaogg committed Oct 31, 2024
1 parent f67516c commit c87f78d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apis_ontology/signals
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from django.contrib.auth.models import Group



@receiver(user_logged_in)
def add_to_group(sender, user, request, **kwargs):
user_list = os.environ.get("AUTH_LDAP_USER_LIST", "").split(",")
g1, _ = Group.objects.get_or_create(name='editors')
if user.username in user_list:
g1.user_set.add(user)

0 comments on commit c87f78d

Please sign in to comment.