From faf893a428cd0f5ce967f44b9aaec9ab12770847 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 7 Mar 2017 21:15:15 -0800 Subject: [PATCH] Fix broken login form with new error responses --- etiquette_site.py | 6 +++++- templates/login.html | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/etiquette_site.py b/etiquette_site.py index 0d0d0d8..eea3c62 100644 --- a/etiquette_site.py +++ b/etiquette_site.py @@ -241,7 +241,11 @@ def post_register(): password_2 = request.form['password_2'] if password_1 != password_2: - return jsonify.make_json_response({'error': 'Passwords do not match'}, status=422) + response = { + 'error_type': 'PASSWORDS_DONT_MATCH', + 'error_message': 'Passwords do not match.', + } + return jsonify.make_json_response(response, status=422) try: user = P.register_user(username, password_1) diff --git a/templates/login.html b/templates/login.html index 4779919..ed6a4f6 100644 --- a/templates/login.html +++ b/templates/login.html @@ -103,7 +103,7 @@ function submit_login() var password = document.getElementById("login_input_password").value; if (username == "" || password == "") { - create_message_bubble(message_area, "message_negative", "Fill out the form yo", 8000); + create_message_bubble(message_area, "message_negative", "Fill out the form, yo.", 8000); return; } var url = "/login"; @@ -119,7 +119,7 @@ function submit_register() var password_2 = document.getElementById("register_input_password_2").value; if (username == "" || password_1 == "" || password_2 == "") { - create_message_bubble(message_area, "message_negative", "Fill out the form yo", 8000); + create_message_bubble(message_area, "message_negative", "Fill out the form, yo.", 8000); return; } var url = "/register"; @@ -131,9 +131,9 @@ function submit_register() } function receive_callback(response) { - if ("error" in response) + if ("error_type" in response) { - create_message_bubble(message_area, "message_negative", response["error"], 8000); + create_message_bubble(message_area, "message_negative", response["error_message"], 8000); } else {