diff --git a/cvat/apps/authentication/auth_ldap.py b/cvat/apps/authentication/auth_ldap.py index 821a99ba..1c1cee2b 100644 --- a/cvat/apps/authentication/auth_ldap.py +++ b/cvat/apps/authentication/auth_ldap.py @@ -25,5 +25,9 @@ def create_user(sender, user=None, ldap_user=None, **kwargs): if role == AUTH_ROLE.ADMIN: user.is_staff = user.is_superuser = True - user.groups.set(user_groups) + # It is important to save the user before adding groups. Please read + # https://django-auth-ldap.readthedocs.io/en/latest/users.html#populating-users + # The user instance will be saved automatically after the signal handler + # is run. user.save() + user.groups.set(user_groups)