mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-01 00:38:42 -04:00
Factor out user id validation checks
This commit is contained in:
parent
57976f646f
commit
f88db7ac0b
2 changed files with 13 additions and 9 deletions
|
@ -27,7 +27,6 @@ from hashlib import sha1
|
|||
import hmac
|
||||
import simplejson as json
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -263,14 +262,11 @@ class RegisterRestServlet(ClientV1RestServlet):
|
|||
)
|
||||
|
||||
password = register_json["password"].encode("utf-8")
|
||||
desired_user_id = (register_json["user"].encode("utf-8")
|
||||
if "user" in register_json else None)
|
||||
if (desired_user_id
|
||||
and urllib.quote(desired_user_id) != desired_user_id):
|
||||
raise SynapseError(
|
||||
400,
|
||||
"User ID must only contain characters which do not " +
|
||||
"require URL encoding.")
|
||||
desired_user_id = (
|
||||
register_json["user"].encode("utf-8")
|
||||
if "user" in register_json else None
|
||||
)
|
||||
|
||||
handler = self.handlers.registration_handler
|
||||
(user_id, token) = yield handler.register(
|
||||
localpart=desired_user_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue