[PATCH 2/6] Warn when user not in the allowed list.

Pierre-Yves Chibon pingou at pingoured.fr
Mon Jan 7 20:26:13 UTC 2013


At the moment when a user is not in the list of allowed user, the
application fails silently.
This commit adds an information message to the user explaining that
something happens but that he cannot log in as he is just not
allowed.
---
 coprs_frontend/coprs/views/misc.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/coprs_frontend/coprs/views/misc.py b/coprs_frontend/coprs/views/misc.py
index ca67c75..be4be05 100644
--- a/coprs_frontend/coprs/views/misc.py
+++ b/coprs_frontend/coprs/views/misc.py
@@ -19,8 +19,14 @@ def login():
         return flask.redirect(oid.get_next_url())
     if flask.request.method == 'POST':
         fasusername = flask.request.form.get('fasuname')
-        if fasusername and ((app.config['USE_ALLOWED_USERS'] and fasusername in app.config['ALLOWED_USERS']) or not app.config['USE_ALLOWED_USERS']):
+        if fasusername and ((app.config['USE_ALLOWED_USERS'] \
+            and fasusername in app.config['ALLOWED_USERS']) \
+            or not app.config['USE_ALLOWED_USERS']):
             return oid.try_login('http://{0}.id.fedoraproject.org/'.format(fasusername), ask_for = ["email"])
+        else:
+            return flask.render_template('login.html',
+                            error='User "{0}" is not allowed'.format(
+                            fasusername))
     return flask.render_template('login.html',
                                  next=oid.get_next_url(),
                                  error=oid.fetch_error())
-- 
1.7.1



More information about the copr-devel mailing list