mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 20:07:49 +01:00
refac
This commit is contained in:
@@ -377,10 +377,13 @@ def get_current_user_by_api_key(request, api_key: str):
|
||||
detail=ERROR_MESSAGES.INVALID_TOKEN,
|
||||
)
|
||||
|
||||
if not request.state.enable_api_keys or not has_permission(
|
||||
user.id,
|
||||
"features.api_keys",
|
||||
request.app.state.config.USER_PERMISSIONS,
|
||||
if not request.state.enable_api_keys or (
|
||||
user.role != "admin"
|
||||
and not has_permission(
|
||||
user.id,
|
||||
"features.api_keys",
|
||||
request.app.state.config.USER_PERMISSIONS,
|
||||
)
|
||||
):
|
||||
raise HTTPException(
|
||||
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.API_KEY_NOT_ALLOWED
|
||||
|
||||
Reference in New Issue
Block a user