🚑 fix quivr api key types (#1022)

This commit is contained in:
Zineb El Bachiri 2023-08-22 18:10:17 +02:00 committed by GitHub
parent 9c7a2aa7c0
commit 0ca25e2af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,4 @@
from datetime import datetime
from uuid import UUID
from fastapi import HTTPException
from models.settings import get_supabase_db
@ -14,7 +13,7 @@ async def verify_api_key(
# Use UTC time to avoid timezone issues
current_date = datetime.utcnow().date()
supabase_db = get_supabase_db()
result = supabase_db.get_active_api_key(UUID(api_key))
result = supabase_db.get_active_api_key(api_key)
if result.data is not None and len(result.data) > 0:
api_key_creation_date = datetime.strptime(
@ -37,7 +36,7 @@ async def get_user_from_api_key(
supabase_db = get_supabase_db()
# Lookup the user_id from the api_keys table
user_id_data = supabase_db.get_user_id_by_api_key(UUID(api_key))
user_id_data = supabase_db.get_user_id_by_api_key(api_key)
if not user_id_data.data:
raise HTTPException(status_code=400, detail="Invalid API key.")

View File

@ -81,7 +81,7 @@ class UserUsage(Repository):
.select("email")
.filter("user_id", "eq", user_id)
.execute()
)
).data
if response and len(response) > 0:
return response[0]["email"]