Allow setting display name during registration.

This commit is contained in:
voussoir 2019-08-26 14:32:51 -07:00
parent 6635a1e740
commit 7ecfeca96c
3 changed files with 7 additions and 3 deletions

View file

@ -106,6 +106,7 @@ def post_register():
return jsonify.make_json_response(response, status=403)
username = request.form['username']
display_name = request.form.get('display_name', None)
password_1 = request.form['password_1']
password_2 = request.form['password_2']
@ -116,7 +117,7 @@ def post_register():
}
return jsonify.make_json_response(response, status=422)
user = common.P.register_user(username, password_1)
user = common.P.register_user(username, password_1, display_name=display_name)
session = sessions.Session(request, user)
session_manager.add(session)

View file

@ -269,11 +269,12 @@ function logout(callback)
}
api.users.register =
function register(username, password_1, password_2, callback)
function register(username, display_name, password_1, password_2, callback)
{
var url = "/register";
data = new FormData();
data.append("username", username);
data.append("display_name", display_name);
data.append("password_1", password_1);
data.append("password_2", password_2);
common.post(url, data, callback);

View file

@ -77,6 +77,7 @@ button
<div id="register_form" class="panel" action="/register" method="post">
<h2>Register</h2>
<input type="text" id="register_input_username" name="username" placeholder="username (at least {{min_username_length}})">
<input type="text" id="register_input_display_name" name="display_name" placeholder="display name (optional)">
<input type="password" id="register_input_password_1" name="password_1" placeholder="password (at least {{min_password_length}})">
<input type="password" id="register_input_password_2" name="password_2" placeholder="password again">
<button type="submit" id="register_input_button" class="green_button" onclick="register_form()">Register</button>
@ -120,6 +121,7 @@ function login_form()
function register_form()
{
var username = document.getElementById("register_input_username").value;
var display_name = document.getElementById("register_input_display_name").value;
var password_1 = document.getElementById("register_input_password_1").value;
var password_2 = document.getElementById("register_input_password_2").value;
if (username == "" || password_1 == "" || password_2 == "")
@ -127,7 +129,7 @@ function register_form()
common.create_message_bubble(message_area, "message_negative", "Fill out the form, yo.");
return;
}
api.users.register(username, password_1, password_2, receive_callback);
api.users.register(username, display_name, password_1, password_2, receive_callback);
}
function receive_callback(response)