mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-24 15:20:24 -04:00
Fix a bug in automatic user creation with m.login.jwt. (#7585)
This commit is contained in:
parent
33c39ab93c
commit
fe434cd3c9
3 changed files with 162 additions and 7 deletions
|
@ -299,7 +299,7 @@ class LoginRestServlet(RestServlet):
|
|||
return result
|
||||
|
||||
async def _complete_login(
|
||||
self, user_id, login_submission, callback=None, create_non_existant_users=False
|
||||
self, user_id, login_submission, callback=None, create_non_existent_users=False
|
||||
):
|
||||
"""Called when we've successfully authed the user and now need to
|
||||
actually login them in (e.g. create devices). This gets called on
|
||||
|
@ -312,7 +312,7 @@ class LoginRestServlet(RestServlet):
|
|||
user_id (str): ID of the user to register.
|
||||
login_submission (dict): Dictionary of login information.
|
||||
callback (func|None): Callback function to run after registration.
|
||||
create_non_existant_users (bool): Whether to create the user if
|
||||
create_non_existent_users (bool): Whether to create the user if
|
||||
they don't exist. Defaults to False.
|
||||
|
||||
Returns:
|
||||
|
@ -331,12 +331,13 @@ class LoginRestServlet(RestServlet):
|
|||
update=True,
|
||||
)
|
||||
|
||||
if create_non_existant_users:
|
||||
user_id = await self.auth_handler.check_user_exists(user_id)
|
||||
if not user_id:
|
||||
user_id = await self.registration_handler.register_user(
|
||||
if create_non_existent_users:
|
||||
canonical_uid = await self.auth_handler.check_user_exists(user_id)
|
||||
if not canonical_uid:
|
||||
canonical_uid = await self.registration_handler.register_user(
|
||||
localpart=UserID.from_string(user_id).localpart
|
||||
)
|
||||
user_id = canonical_uid
|
||||
|
||||
device_id = login_submission.get("device_id")
|
||||
initial_display_name = login_submission.get("initial_device_display_name")
|
||||
|
@ -391,7 +392,7 @@ class LoginRestServlet(RestServlet):
|
|||
|
||||
user_id = UserID(user, self.hs.hostname).to_string()
|
||||
result = await self._complete_login(
|
||||
user_id, login_submission, create_non_existant_users=True
|
||||
user_id, login_submission, create_non_existent_users=True
|
||||
)
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue