Fix broken login form with new error responses

This commit is contained in:
voussoir 2017-03-07 21:15:15 -08:00
parent aa6ed364a9
commit faf893a428
2 changed files with 9 additions and 5 deletions

View file

@ -241,7 +241,11 @@ def post_register():
password_2 = request.form['password_2'] password_2 = request.form['password_2']
if password_1 != 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: try:
user = P.register_user(username, password_1) user = P.register_user(username, password_1)

View file

@ -103,7 +103,7 @@ function submit_login()
var password = document.getElementById("login_input_password").value; var password = document.getElementById("login_input_password").value;
if (username == "" || password == "") 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; return;
} }
var url = "/login"; var url = "/login";
@ -119,7 +119,7 @@ function submit_register()
var password_2 = document.getElementById("register_input_password_2").value; var password_2 = document.getElementById("register_input_password_2").value;
if (username == "" || password_1 == "" || password_2 == "") 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; return;
} }
var url = "/register"; var url = "/register";
@ -131,9 +131,9 @@ function submit_register()
} }
function receive_callback(response) 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 else
{ {