فهرست منبع

Put the first user to login in the default group

When using the AllowFirstUserDjangoBackend, the first user is allowed to log in
with any password they want. This change will make sure that the user is also
added to the default group, if one is configured.
Jon Natkins 14 سال پیش
والد
کامیت
37b61c76c0
1فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 6 0
      desktop/core/src/desktop/auth/backend.py

+ 6 - 0
desktop/core/src/desktop/auth/backend.py

@@ -157,6 +157,12 @@ class AllowFirstUserDjangoBackend(django.contrib.auth.backends.ModelBackend):
     if self.is_first_login_ever():
     if self.is_first_login_ever():
       user = find_or_create_user(username, password)
       user = find_or_create_user(username, password)
       user = rewrite_user(user)
       user = rewrite_user(user)
+
+      default_group = get_default_user_group()
+      if default_group is not None:
+        user.groups.add(default_group)
+        user.save()
+
       return user
       return user
 
 
     return None
     return None