From f1613217d6e94f640957c23942b1e2c44f4e1af8 Mon Sep 17 00:00:00 2001
From: Maxi Schulz <maximilian.schulz@hs-hannover.de>
Date: Fri, 9 Feb 2018 14:48:09 +0100
Subject: [PATCH] Make DevBackend dev again

---
 ssoauth/auth_utils.py | 4 ++--
 ssoauth/views.py      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ssoauth/auth_utils.py b/ssoauth/auth_utils.py
index 79964fc..383c229 100644
--- a/ssoauth/auth_utils.py
+++ b/ssoauth/auth_utils.py
@@ -136,7 +136,7 @@ def cleanup_direct_permissions(user):
         user.user_permissions.clear()
 
 
-def set_user_compat_flags(user):
+def set_user_compat_flags(user, check_login_perm=True):
 
     def get_full_perm_name(codename):
         return "{app}.{codename}".format(
@@ -162,7 +162,7 @@ def set_user_compat_flags(user):
         logger.info("User {user} is staff (has admin access).".format(**locals()))
         user.is_staff = True
     # is_active (actually represents the log in permission)
-    if app_settings.LOGIN_PERM_CODENAME:
+    if app_settings.LOGIN_PERM_CODENAME and check_login_perm:
         if user.has_perm(get_full_perm_name(app_settings.LOGIN_PERM_CODENAME)):
             logger.info("User {user} is active.".format(**locals()))
             user.is_active = True
diff --git a/ssoauth/views.py b/ssoauth/views.py
index 05a42f0..4d9553c 100644
--- a/ssoauth/views.py
+++ b/ssoauth/views.py
@@ -350,7 +350,7 @@ class DevView(FormView):
             contrib_auth.logout(self.request)
         # update the compat flags, might be needed when user or their groups change
         if self.request.user.is_authenticated:
-            auth_utils.set_user_compat_flags(self.request.user)
+            auth_utils.set_user_compat_flags(self.request.user, False)
         # redirect
         return http.HttpResponseRedirect(self.next_url or urls.reverse("sso-dev"))
 
-- 
GitLab