From 5e80077fae6495901e9c7576995ded06a1dde5c8 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 12 Jan 2015 12:52:40 +0200 Subject: client/server: login is using POST, so use POST, not XMLHttpRequest TODO: Logout requires styling plus only to appear if logged in. --- res/client/css/partials/top-bar.scss | 6 +++++- res/client/css/style.css | 3 +++ res/templates/index.html | 2 +- res/templates/login.html | 27 +++------------------------ src/client/buttons.js | 5 ----- src/server/rz_api.py | 6 +++++- 6 files changed, 17 insertions(+), 32 deletions(-) diff --git a/res/client/css/partials/top-bar.scss b/res/client/css/partials/top-bar.scss index cffd200a..5aec704c 100644 --- a/res/client/css/partials/top-bar.scss +++ b/res/client/css/partials/top-bar.scss @@ -57,4 +57,8 @@ background: url(../img/CRI-logo.png); min-height: 30px; min-width: 30px; -} \ No newline at end of file +} + +.logout-form { + display: inline; +} diff --git a/res/client/css/style.css b/res/client/css/style.css index b6231384..b4008d93 100644 --- a/res/client/css/style.css +++ b/res/client/css/style.css @@ -826,6 +826,9 @@ body.debug .debug-ui-right { min-height: 30px; min-width: 30px; } +.logout-form { + display: inline; } + /* Headings */ h1 { font-size: 30px; } diff --git a/res/templates/index.html b/res/templates/index.html index 13913ba2..6ef39e25 100644 --- a/res/templates/index.html +++ b/res/templates/index.html @@ -23,7 +23,7 @@
AN -
Welcome Anonymous! Logout
+
Welcome Anonymous!
diff --git a/res/templates/login.html b/res/templates/login.html index f35bccdc..3e32eee3 100644 --- a/res/templates/login.html +++ b/res/templates/login.html @@ -4,28 +4,7 @@ Welcome to Rhizi - -
@@ -39,9 +18,9 @@
-
- - + + + forgot password?
diff --git a/src/client/buttons.js b/src/client/buttons.js index e29a1729..5fd8d121 100644 --- a/src/client/buttons.js +++ b/src/client/buttons.js @@ -67,11 +67,6 @@ $('.local-storage-load a').click(function(){ rz_core.load_from_json(json_blob); }); -var logout_button = $('#logout-button'); -logout_button.click(function() { - $.ajax({ type: "POST", url: '/logout'}); // server should redirect back to /login -}); - $('a.save-history').click(function() { if (rz_core.main_graph.history === undefined) { throw "History is undefined"; diff --git a/src/server/rz_api.py b/src/server/rz_api.py index 3b6d9585..fc2e2343 100644 --- a/src/server/rz_api.py +++ b/src/server/rz_api.py @@ -170,7 +170,7 @@ def index(): def login(): def sanitize_input(req): - req_json = request.get_json() + req_json = request.form.to_dict() u = req_json['username'] p = req_json['password'] return u, p @@ -178,6 +178,10 @@ def login(): if request.method == 'POST': try: u, p = sanitize_input(request) + except: + log.warn('failed to sanitize inputs. request: %s' % request) + return render_template('login.html', login_failed=True) + try: crypt_util.validate_login(flask.current_app.rz_config, u, p) except Exception as e: # login failed -- cgit v1.3.1