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 4 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;
}
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, {
"credentials": "include",
}).then((response) => {

@ -155,6 +155,8 @@ class SubmitResource(AsyncResource):
_return_html_error(400, "missing username", request)
return
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)
try:
registered_user_id = await self._module_api.register_user(

Loading…
Cancel
Save