User /login Admin API: check if user exists first
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user