allow using hashed api keys on regen key

This commit is contained in:
Ishaan Jaff 2024-08-26 18:15:52 -07:00
parent 6b8bb69af3
commit 2615edc468

View file

@ -1008,7 +1008,11 @@ async def regenerate_key_fn(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail={"error": "DB not connected. prisma_client is None"}, detail={"error": "DB not connected. prisma_client is None"},
) )
hashed_api_key = hash_token(key)
if "sk" not in key:
hashed_api_key = key
else:
hashed_api_key = hash_token(key)
_key_in_db = await prisma_client.db.litellm_verificationtoken.find_unique( _key_in_db = await prisma_client.db.litellm_verificationtoken.find_unique(
where={"token": hashed_api_key}, where={"token": hashed_api_key},