mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-08-09 05:52:13 -04:00
Allow registering invalid user IDs with admin API
This commit is contained in:
parent
c79b058cff
commit
5ec53ac808
1 changed files with 27 additions and 21 deletions
|
@ -70,8 +70,10 @@ class RegistrationHandler(BaseHandler):
|
||||||
self.session_lifetime = hs.config.session_lifetime
|
self.session_lifetime = hs.config.session_lifetime
|
||||||
|
|
||||||
async def check_username(
|
async def check_username(
|
||||||
self, localpart, guest_access_token=None, assigned_user_id=None
|
self, localpart, guest_access_token=None, assigned_user_id=None, allow_invalid=False
|
||||||
):
|
):
|
||||||
|
# meow: allow admins to register invalid user ids
|
||||||
|
if not allow_invalid:
|
||||||
if types.contains_invalid_mxid_characters(localpart):
|
if types.contains_invalid_mxid_characters(localpart):
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400,
|
400,
|
||||||
|
@ -99,6 +101,8 @@ class RegistrationHandler(BaseHandler):
|
||||||
"A different user ID has already been registered for this session",
|
"A different user ID has already been registered for this session",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# meow: allow admins to register reserved user ids and long user ids
|
||||||
|
if not allow_invalid:
|
||||||
self.check_user_id_not_appservice_exclusive(user_id)
|
self.check_user_id_not_appservice_exclusive(user_id)
|
||||||
|
|
||||||
if len(user_id) > MAX_USERID_LENGTH:
|
if len(user_id) > MAX_USERID_LENGTH:
|
||||||
|
@ -200,7 +204,9 @@ class RegistrationHandler(BaseHandler):
|
||||||
await self.auth.check_auth_blocking(threepid=threepid)
|
await self.auth.check_auth_blocking(threepid=threepid)
|
||||||
|
|
||||||
if localpart is not None:
|
if localpart is not None:
|
||||||
await self.check_username(localpart, guest_access_token=guest_access_token)
|
allow_invalid = by_admin and self.hs.config.meow.admin_api_register_invalid
|
||||||
|
await self.check_username(localpart, guest_access_token=guest_access_token,
|
||||||
|
allow_invalid=allow_invalid)
|
||||||
|
|
||||||
was_guest = guest_access_token is not None
|
was_guest = guest_access_token is not None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue