allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [04/10] allura git commit: [#8117] remove an unnecessary try/except/re-raise
Date Tue, 06 Sep 2016 14:50:37 GMT
[#8117] remove an unnecessary try/except/re-raise


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/80978125
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/80978125
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/80978125

Branch: refs/heads/master
Commit: 80978125e832f295701c726a5ffb413e60b2bf44
Parents: a733a05
Author: Dave Brondsema <dave@brondsema.net>
Authored: Tue Aug 23 14:51:42 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Tue Sep 6 10:38:51 2016 -0400

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py               | 49 ++++++++++++--------------
 Allura/allura/lib/widgets/auth_widgets.py |  2 +-
 Allura/allura/templates/login.html        |  2 +-
 3 files changed, 25 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/80978125/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index f74dc62..cd4f336 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -147,33 +147,30 @@ class AuthenticationProvider(object):
         raise NotImplementedError('_login')
 
     def login(self, user=None):
-        try:
-            if user is None:
-                user = self._login()
-            if self.is_password_expired(user):
-                self.session['pwd-expired'] = True
-                self.session['expired-username'] = user.username
-                h.auditlog_user('Password expired', user=user)
-            else:
-                self.session['username'] = user.username
+        if user is None:
+            user = self._login()  # raises exception if auth fails
 
-            if 'rememberme' in self.request.params:
-                remember_for = int(config.get('auth.remember_for', 365))
-                self.session['login_expires'] = datetime.utcnow() + timedelta(remember_for)
-            else:
-                self.session['login_expires'] = True
-            self.session.save()
-            g.statsUpdater.addUserLogin(user)
-            user.track_login(self.request)
-            # set a non-secure cookie with same expiration as session,
-            # so an http request can know if there is a related session on https
-            response.set_cookie('allura-loggedin', value='true',
-                                expires=None if self.session['login_expires'] is True else
self.session['login_expires'],
-                                secure=False, httponly=True)
-            return user
-        except exc.HTTPUnauthorized:
-            self.logout()
-            raise
+        if self.is_password_expired(user):
+            self.session['pwd-expired'] = True
+            self.session['expired-username'] = user.username
+            h.auditlog_user('Password expired', user=user)
+        else:
+            self.session['username'] = user.username
+
+        if 'rememberme' in self.request.params:
+            remember_for = int(config.get('auth.remember_for', 365))
+            self.session['login_expires'] = datetime.utcnow() + timedelta(remember_for)
+        else:
+            self.session['login_expires'] = True
+        self.session.save()
+        g.statsUpdater.addUserLogin(user)
+        user.track_login(self.request)
+        # set a non-secure cookie with same expiration as session,
+        # so an http request can know if there is a related session on https
+        response.set_cookie('allura-loggedin', value='true',
+                            expires=None if self.session['login_expires'] is True else self.session['login_expires'],
+                            secure=False, httponly=True)
+        return user
 
     def logout(self):
         self.session.invalidate()

http://git-wip-us.apache.org/repos/asf/allura/blob/80978125/Allura/allura/lib/widgets/auth_widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/auth_widgets.py b/Allura/allura/lib/widgets/auth_widgets.py
index 22f4429..f2ba4e7 100644
--- a/Allura/allura/lib/widgets/auth_widgets.py
+++ b/Allura/allura/lib/widgets/auth_widgets.py
@@ -58,7 +58,7 @@ class LoginForm(ForgeForm):
     @validator
     def validate(self, value, state=None):
         try:
-            value['username'] = plugin.AuthenticationProvider.get(request).login()
+            plugin.AuthenticationProvider.get(request).login()
         except exc.HTTPUnauthorized:
             msg = 'Invalid login'
             raise Invalid(

http://git-wip-us.apache.org/repos/asf/allura/blob/80978125/Allura/allura/templates/login.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/login.html b/Allura/allura/templates/login.html
index 4037878..7fa5c3e 100644
--- a/Allura/allura/templates/login.html
+++ b/Allura/allura/templates/login.html
@@ -19,7 +19,7 @@
 {% set hide_left_bar = True %}
 {% extends g.theme.master %}
 
-{% block title %}Login Form{% endblock %}
+{% block title %}{{ config['site_name'] }} Login{% endblock %}
 
 {% block header %}Login{% endblock %}
 


Mime
View raw message