diff rhodecode/lib/auth.py @ 1618:9353189b7675 beta

Added automatic logout of deactivated/deleted users
author Liad Shani <liadff@gmail.com>
date Thu, 27 Oct 2011 20:40:49 +0200
parents cf128ced8c85
children cbc2b1913cdf
line wrap: on
line diff
--- a/rhodecode/lib/auth.py	Wed Oct 26 21:59:22 2011 +0200
+++ b/rhodecode/lib/auth.py	Thu Oct 27 20:40:49 2011 +0200
@@ -271,13 +271,11 @@
         if self._api_key and self._api_key != self.anonymous_user.api_key:
             #try go get user by api key
             log.debug('Auth User lookup by API KEY %s', self._api_key)
-            user_model.fill_data(self, api_key=self._api_key)
-            is_user_loaded = True
+            is_user_loaded = user_model.fill_data(self, api_key=self._api_key)
         elif self.user_id is not None \
             and self.user_id != self.anonymous_user.user_id:
             log.debug('Auth User lookup by USER ID %s', self.user_id)
-            user_model.fill_data(self, user_id=self.user_id)
-            is_user_loaded = True
+            is_user_loaded = user_model.fill_data(self, user_id=self.user_id)
         elif self.username:
             log.debug('Auth User lookup by USER NAME %s', self.username)
             dbuser = User.get_by_username(self.username)
@@ -296,6 +294,8 @@
                 #then we set this user is logged in
                 self.is_authenticated = True
             else:
+                self.user_id = None
+                self.username = None
                 self.is_authenticated = False
 
         if not self.username: