Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Downcase userid on registration
Browse files Browse the repository at this point in the history
Force username to lowercase before attempting to register

#2660
  • Loading branch information
richvdh committed Nov 9, 2017
1 parent 9b803cc commit 9b599bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def on_POST(self, request):
# 'user' key not 'username'). Since this is a new addition, we'll
# fallback to 'username' if they gave one.
desired_username = body.get("user", desired_username)

# XXX we should check that desired_username is valid

access_token = get_access_token_from_request(request)

if isinstance(desired_username, basestring):
Expand Down Expand Up @@ -273,7 +276,7 @@ def on_POST(self, request):

if desired_username is not None:
yield self.registration_handler.check_username(
desired_username,
desired_username.lower(),
guest_access_token=guest_access_token,
assigned_user_id=registered_user_id,
)
Expand Down Expand Up @@ -336,6 +339,9 @@ def on_POST(self, request):
new_password = params.get("password", None)
guest_access_token = params.get("guest_access_token", None)

if desired_username is not None:
desired_username = desired_username.lower()

(registered_user_id, _) = yield self.registration_handler.register(
localpart=desired_username,
password=new_password,
Expand Down

0 comments on commit 9b599bc

Please sign in to comment.