Handle username/password logins.
(request: Request, body: LoginSchema)
| 404 | # TODO annotate response type |
| 405 | @public_route |
| 406 | async def auth_login(request: Request, body: LoginSchema) -> JSONResponse: |
| 407 | """ |
| 408 | Handle username/password logins. |
| 409 | """ |
| 410 | supabase = get_supabase() |
| 411 | # returns `AuthResponse` (.venv/lib/python3.12/site-packages/gotrue/types.py:95) |
| 412 | try: |
| 413 | auth_response = supabase.auth.sign_in_with_password( |
| 414 | { |
| 415 | 'email': body.email, |
| 416 | 'password': body.password, |
| 417 | } |
| 418 | ) |
| 419 | except gotrue.errors.AuthApiError as e: |
| 420 | raise AuthException.from_gotrue_autherror(e) |
| 421 | |
| 422 | if hasattr(auth_response, 'error'): |
| 423 | raise AuthException() |
| 424 | |
| 425 | access_token = auth_response.session.access_token |
| 426 | content = StatusResponse(message="User authenticated successfully.") |
| 427 | response = JSONResponse(content=content.model_dump()) |
| 428 | return _create_session_for_response(response, access_token) |
| 429 | |
| 430 | |
| 431 | @public_route |
nothing calls this directly
no test coverage detected
searching dependent graphs…