Turn the chosen username to lowercase

So that the user doesn't get dumped to a CSS-less error page telling
them that the localpart doesn't match the regexp.
master
Brendan Abolivier 5 years ago
parent 956f84c42b
commit ea7ba3e969
No known key found for this signature in database
GPG Key ID: 1E015C145F1916CD

@ -65,7 +65,9 @@ let submitUsername = function(username) {
return; return;
} }
let check_uri = 'check?' + buildQueryString({"username": username}); // Since we're trying to register the username converted to lower case, check the
// availability with the right case.
let check_uri = 'check?' + buildQueryString({"username": username.toLowerCase()});
fetch(check_uri, { fetch(check_uri, {
"credentials": "include", "credentials": "include",
}).then((response) => { }).then((response) => {

@ -155,6 +155,8 @@ class SubmitResource(AsyncResource):
_return_html_error(400, "missing username", request) _return_html_error(400, "missing username", request)
return return
localpart = request.args[b"username"][0].decode("utf-8", errors="replace") localpart = request.args[b"username"][0].decode("utf-8", errors="replace")
# Convert the username to lower case.
localpart = localpart.lower()
logger.info("Registering username %s", localpart) logger.info("Registering username %s", localpart)
try: try:
registered_user_id = await self._module_api.register_user( registered_user_id = await self._module_api.register_user(

Loading…
Cancel
Save