Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Move get_settings_service out of Depends() #4239

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/backend/base/langflow/api/v1/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,20 @@
router = APIRouter(prefix="/store", tags=["Components Store"])


def get_user_store_api_key(
user: CurrentActiveUser,
settings_service=Depends(get_settings_service),
):
def get_user_store_api_key(user: CurrentActiveUser):
if not user.store_api_key:
raise HTTPException(status_code=400, detail="You must have a store API key set.")
try:
return auth_utils.decrypt_api_key(user.store_api_key, settings_service)
return auth_utils.decrypt_api_key(user.store_api_key, get_settings_service())
except Exception as e:
raise HTTPException(status_code=500, detail="Failed to decrypt API key. Please set a new one.") from e


def get_optional_user_store_api_key(
user: CurrentActiveUser,
settings_service=Depends(get_settings_service),
):
def get_optional_user_store_api_key(user: CurrentActiveUser):
if not user.store_api_key:
return None
try:
return auth_utils.decrypt_api_key(user.store_api_key, settings_service)
return auth_utils.decrypt_api_key(user.store_api_key, get_settings_service())
except Exception: # noqa: BLE001
logger.exception("Failed to decrypt API key")
return user.store_api_key
Expand Down
Loading