summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-09-10 20:07:13 +0300
committerLars Wirzenius <liw@liw.fi>2018-09-10 20:07:13 +0300
commit8bc86543252108b5491b4c4e060f437b0480ca66 (patch)
treec18b90f8732e071bc3204347a8d491fd7250ad3a
parent23b2f4d5ee90be543d73a811295884949424369a (diff)
downloadqvisqve-8bc86543252108b5491b4c4e060f437b0480ca66.tar.gz
Change: move login form to a separate file
-rw-r--r--qvisqve/auth_router.py26
-rw-r--r--qvisqve/templates/login.tmpl19
-rw-r--r--qvisqve/tmpl.py27
3 files changed, 48 insertions, 24 deletions
diff --git a/qvisqve/auth_router.py b/qvisqve/auth_router.py
index 9dfb582..0da34d3 100644
--- a/qvisqve/auth_router.py
+++ b/qvisqve/auth_router.py
@@ -23,29 +23,6 @@ import bottle
import qvisqve
-login_form = '''
-<!DOCTYPE html>
-<html>
- <head>
- <meta charset="utf-8">
- <meta name="description" content="Qvisqve Login">
- <meta name="author" content="Qvarnlabs Ltd">
- <title>Qvisqve Login</title>
- </head>
- <body>
- <form action="/auth" method="POST">
- <input name="attempt_id" value="{{attempt_id}}" type="hidden" />
- User name: <input name="username" type="text" />
- <br />
- Password: <input name="password" type="password" />
- <br />
- <input type="submit" value="Login" />
- </form>
- </body>
-</html>
-'''
-
-
class AuthRouter(qvisqve.Router):
def __init__(self, apps, users, authz_attempts):
@@ -103,7 +80,8 @@ class AuthRouter(qvisqve.Router):
cleaned['redirect_uri'] = redirect_uri
aa = self._attempts.create_attempt(cleaned)
- form = bottle.template(login_form, attempt_id=aa.get_attempt_id())
+ form = qvisqve.render_template(
+ 'login.tmpl', attempt_id=aa.get_attempt_id())
headers = {
'Content-Type': 'text/html; charset=utf-8',
}
diff --git a/qvisqve/templates/login.tmpl b/qvisqve/templates/login.tmpl
new file mode 100644
index 0000000..3f71e23
--- /dev/null
+++ b/qvisqve/templates/login.tmpl
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta name="description" content="Qvisqve Login">
+ <meta name="author" content="Qvarnlabs Ltd">
+ <title>Qvisqve Login</title>
+ </head>
+ <body>
+ <form action="/auth" method="POST">
+ <input name="attempt_id" value="{{attempt_id}}" type="hidden" />
+ User name: <input name="username" type="text" />
+ <br />
+ Password: <input name="password" type="password" />
+ <br />
+ <input type="submit" value="Login" />
+ </form>
+ </body>
+</html>
diff --git a/qvisqve/tmpl.py b/qvisqve/tmpl.py
new file mode 100644
index 0000000..3d91f02
--- /dev/null
+++ b/qvisqve/tmpl.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2018 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import os
+
+import bottle
+
+import qvisqve
+
+
+def render_template(name, **values):
+ moduledir = os.path.dirname(qvisqve.__file__)
+ dirname = os.path.join(moduledir, 'templates')
+ return bottle.template(name, template_lookup=[dirname], **values)