mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-08 12:42:12 -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
|
@ -31,6 +31,7 @@ import base64
|
|||
import bcrypt
|
||||
import json
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -63,6 +64,13 @@ class RegistrationHandler(BaseHandler):
|
|||
password_hash = bcrypt.hashpw(password, bcrypt.gensalt())
|
||||
|
||||
if localpart:
|
||||
if localpart and urllib.quote(localpart) != localpart:
|
||||
raise SynapseError(
|
||||
400,
|
||||
"User ID must only contain characters which do not"
|
||||
" require URL encoding."
|
||||
)
|
||||
|
||||
user = UserID(localpart, self.hs.hostname)
|
||||
user_id = user.to_string()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue