forked from MirrorHub/synapse
Allow registering invalid user IDs with admin API
This commit is contained in:
parent
5144582e6e
commit
b532218842
1 changed files with 35 additions and 25 deletions
|
@ -141,8 +141,11 @@ class RegistrationHandler:
|
||||||
localpart: str,
|
localpart: str,
|
||||||
guest_access_token: Optional[str] = None,
|
guest_access_token: Optional[str] = None,
|
||||||
assigned_user_id: Optional[str] = None,
|
assigned_user_id: Optional[str] = None,
|
||||||
|
allow_invalid: bool = False,
|
||||||
inhibit_user_in_use_error: bool = False,
|
inhibit_user_in_use_error: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# meow: allow admins to register invalid user ids
|
||||||
|
if not allow_invalid:
|
||||||
if types.contains_invalid_mxid_characters(
|
if types.contains_invalid_mxid_characters(
|
||||||
localpart, self.hs.config.experimental.msc4009_e164_mxids
|
localpart, self.hs.config.experimental.msc4009_e164_mxids
|
||||||
):
|
):
|
||||||
|
@ -175,6 +178,8 @@ class RegistrationHandler:
|
||||||
"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:
|
||||||
|
@ -288,7 +293,12 @@ class RegistrationHandler:
|
||||||
await self.auth_blocking.check_auth_blocking(threepid=threepid)
|
await self.auth_blocking.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…
Reference in a new issue