mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
682013cee3
commit
288947a648
1 changed files with 7 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue