changeset 5546:95bc1801d480

auth: inline AuthUser.set_authenticated This makes the following commits easier to follow, and makes it more explicit that something weird is going on, with more cleanup needed.
author Søren Løvborg <sorenl@unity3d.com>
date Wed, 09 Sep 2015 12:21:25 +0200
parents ba30adf2fb8a
children c64c076b96c3
files kallithea/lib/auth.py kallithea/lib/base.py
diffstat 2 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/auth.py	Tue Oct 06 19:22:22 2015 +0200
+++ b/kallithea/lib/auth.py	Wed Sep 09 12:21:25 2015 +0200
@@ -626,10 +626,6 @@
         return "<AuthUser('id:%s[%s] auth:%s')>"\
             % (self.user_id, self.username, self.is_authenticated)
 
-    def set_authenticated(self, authenticated=True):
-        if not self.is_default_user:
-            self.is_authenticated = authenticated
-
     def to_cookie(self):
         """ Serializes this login session to a cookie `dict`. """
         return {
@@ -650,7 +646,8 @@
         )
         if not au.is_authenticated and au.user_id is not None:
             # user is not authenticated and not empty
-            au.set_authenticated(cookie.get('is_authenticated'))
+            if not au.is_default_user:
+                au.is_authenticated = cookie.get('is_authenticated')
         return au
 
     @classmethod
--- a/kallithea/lib/base.py	Tue Oct 06 19:22:22 2015 +0200
+++ b/kallithea/lib/base.py	Wed Sep 09 12:21:25 2015 +0200
@@ -116,7 +116,8 @@
 
     auth_user = AuthUser(dbuser=user,
                          is_external_auth=is_external_auth)
-    auth_user.set_authenticated()
+    if not auth_user.is_default_user:
+        auth_user.is_authenticated = True
 
     # Start new session to prevent session fixation attacks.
     session.invalidate()