[odrs-web] Set the LoginManager view function for login



commit a122ab9f8230ee30e20899873c0407dd549230a4
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jul 25 14:39:03 2019 +0200

    Set the LoginManager view function for login

 app_data/odrs/__init__.py        | 4 ++--
 app_data/odrs/tests/odrs_test.py | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/app_data/odrs/__init__.py b/app_data/odrs/__init__.py
index 82a06a1..9d8729f 100644
--- a/app_data/odrs/__init__.py
+++ b/app_data/odrs/__init__.py
@@ -40,8 +40,8 @@ def initdb_command():
 def dropdb_command():
     drop_db(db)
 
-lm = LoginManager()
-lm.init_app(app)
+lm = LoginManager(app)
+lm.login_view = 'odrs_login'
 
 @app.teardown_appcontext
 def shutdown_session(unused_exception=None):
diff --git a/app_data/odrs/tests/odrs_test.py b/app_data/odrs/tests/odrs_test.py
index 42e4e74..1663d80 100644
--- a/app_data/odrs/tests/odrs_test.py
+++ b/app_data/odrs/tests/odrs_test.py
@@ -639,16 +639,16 @@ class OdrsTest(unittest.TestCase):
                 '/admin/stats',
                 '/admin/moderators/all']
         for uri in uris:
-            rv = self.app.get(uri)
+            rv = self.app.get(uri, follow_redirects=True)
             assert b'favicon.ico' in rv.data, rv.data
-            assert b'Permission denied' in rv.data, (uri, rv.data)
+            assert b'Please log in to access this page' in rv.data, (uri, rv.data)
 
         # POST only
         uris = ['/admin/modify/1']
         for uri in uris:
-            rv = self.app.post(uri)
+            rv = self.app.post(uri, follow_redirects=True)
             assert b'favicon.ico' in rv.data, rv.data
-            assert b'Permission denied' in rv.data, rv.data
+            assert b'Please log in to access this page' in rv.data, rv.data
 
 if __name__ == '__main__':
     unittest.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]