1
0

User /login Admin API: check if user exists first

This commit is contained in:
Olivier 'reivilibre
2025-06-05 13:01:32 +01:00
parent 0b9f1757a7
commit d37d442376
+5
View File
@@ -1068,6 +1068,7 @@ class UserTokenRestServlet(RestServlet):
self.store = hs.get_datastores().main
self.auth = hs.get_auth()
self.auth_handler = hs.get_auth_handler()
self.admin_handler = hs.get_admin_handler()
self.is_mine_id = hs.is_mine_id
async def on_POST(
@@ -1082,6 +1083,10 @@ class UserTokenRestServlet(RestServlet):
HTTPStatus.BAD_REQUEST, "Only local users can be logged in as"
)
_user_info_dict = await self.admin_handler.get_user(UserID.from_string(user_id))
if not _user_info_dict:
raise NotFoundError("User not found")
body = parse_json_object_from_request(request, allow_empty_body=True)
valid_until_ms = body.get("valid_until_ms")