@@ -32,11 +32,7 @@ async def get_request_body(request: Request):
3232
3333@router .get ("/service-info" , status_code = HTTP_200_OK )
3434async def service_info (request : Request , auth = Depends (Auth )) -> dict :
35- try :
36- token_claims = await auth .get_token_claims ()
37- except Exception :
38- token_claims = {}
39- user_id = token_claims .get ("sub" )
35+ user_id = await auth .get_user_id ()
4036 logger .info (f"User '{ user_id } ' getting TES service info" )
4137
4238 url = f"{ config ['TES_SERVER_URL' ]} /service-info"
@@ -164,11 +160,7 @@ def apply_view_to_task(view: str, task: dict) -> dict:
164160
165161@router .get ("/tasks" , status_code = HTTP_200_OK )
166162async def list_tasks (request : Request , auth = Depends (Auth )) -> dict :
167- try :
168- token_claims = await auth .get_token_claims ()
169- except Exception :
170- token_claims = {}
171- user_id = token_claims .get ("sub" )
163+ user_id = await auth .get_user_id ()
172164 logger .info (f"User '{ user_id } ' listing TES tasks" )
173165
174166 supported_params = {
@@ -231,11 +223,7 @@ async def list_tasks(request: Request, auth=Depends(Auth)) -> dict:
231223
232224@router .get ("/tasks/{task_id}" , status_code = HTTP_200_OK )
233225async def get_task (request : Request , task_id : str , auth = Depends (Auth )) -> dict :
234- try :
235- token_claims = await auth .get_token_claims ()
236- except Exception :
237- token_claims = {}
238- user_id = token_claims .get ("sub" )
226+ user_id = await auth .get_user_id ()
239227 logger .info (f"User '{ user_id } ' getting TES task '{ task_id } '" )
240228
241229 supported_params = {"view" }
@@ -268,11 +256,7 @@ async def get_task(request: Request, task_id: str, auth=Depends(Auth)) -> dict:
268256
269257@router .post ("/tasks/{task_id}:cancel" , status_code = HTTP_200_OK )
270258async def cancel_task (request : Request , task_id : str , auth = Depends (Auth )) -> dict :
271- try :
272- token_claims = await auth .get_token_claims ()
273- except Exception :
274- token_claims = {}
275- user_id = token_claims .get ("sub" )
259+ user_id = await auth .get_user_id ()
276260 logger .info (f"User '{ user_id } ' canceling TES task '{ task_id } '" )
277261
278262 # check if this user has access to delete this task
0 commit comments