Skip to content

Commit

Permalink
Add app state type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
etown committed Feb 6, 2024
1 parent a2a2e7d commit 0b0bfe6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions untitledai/server/app_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ async def _parse_and_verify_token(authorization: str, expected_token: str):

@staticmethod
async def authenticate_request(request: Request, authorization: Optional[str] = Header(None)):
app_state = AppState.get(request)
app_state: AppState = AppState.get(request)
await AppState._parse_and_verify_token(authorization, app_state.config.user.client_token)
return app_state

@staticmethod
async def authenticate_socket(environ: dict):
headers = {k.decode('utf-8').lower(): v.decode('utf-8') for k, v in environ.get('asgi.scope', {}).get('headers', [])}
authorization = headers.get('authorization')
app_state = AppState.get(environ['asgi.scope']['app'])
app_state: AppState = AppState.get(environ['asgi.scope']['app'])
await AppState._parse_and_verify_token(authorization, app_state.config.user.client_token)
return app_state

0 comments on commit 0b0bfe6

Please sign in to comment.