1+ import logging
12from typing import Optional , Union
23from uuid import UUID
34
1415from .db import yield_db_read_only_session
1516from .settings import BOT_INSTALLATION_TOKEN , BOT_INSTALLATION_TOKEN_HEADER
1617
18+ logger = logging .getLogger (__name__ )
19+
1720# Login implementation follows:
1821# https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/
1922oauth2_scheme = OAuth2PasswordBearer (tokenUrl = "token" )
@@ -29,6 +32,7 @@ async def get_current_user(
2932 except actions .TokenNotFound :
3033 raise HTTPException (status_code = 404 , detail = "Access token not found" )
3134 except Exception :
35+ logger .error ("Unhandled exception at get_current_user" )
3236 raise HTTPException (status_code = 500 )
3337 if not token_object .active :
3438 raise HTTPException (status_code = 403 , detail = "Token has expired" )
@@ -46,6 +50,7 @@ async def get_current_user_with_groups(
4650 except actions .TokenNotFound :
4751 raise HTTPException (status_code = 404 , detail = "Access token not found" )
4852 except Exception :
53+ logger .error ("Unhandled exception at get_current_user_with_groups" )
4954 raise HTTPException (status_code = 500 )
5055 if not token_active :
5156 raise HTTPException (status_code = 403 , detail = "Token has expired" )
@@ -123,5 +128,6 @@ async def is_token_restricted(
123128 except actions .TokenNotFound :
124129 raise HTTPException (status_code = 404 , detail = "Access token not found" )
125130 except Exception :
131+ logger .error ("Unhandled exception at is_token_restricted" )
126132 raise HTTPException (status_code = 500 )
127133 return token_object .restricted
0 commit comments