mirror of
https://github.com/open-webui/open-webui
synced 2024-11-22 08:07:55 +00:00
enh: chat file upload permission
This commit is contained in:
parent
f9412f72f1
commit
646d926f70
@ -52,7 +52,7 @@ async def get_session_user_chat_list(
|
|||||||
async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)):
|
async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)):
|
||||||
if user.role == "user" and not request.app.state.config.USER_PERMISSIONS.get(
|
if user.role == "user" and not request.app.state.config.USER_PERMISSIONS.get(
|
||||||
"chat", {}
|
"chat", {}
|
||||||
).get("deletion", {}):
|
).get("delete", {}):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||||
@ -386,7 +386,7 @@ async def delete_chat_by_id(request: Request, id: str, user=Depends(get_verified
|
|||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
if not request.app.state.config.USER_PERMISSIONS.get("chat", {}).get(
|
if not request.app.state.config.USER_PERMISSIONS.get("chat", {}).get(
|
||||||
"deletion", {}
|
"delete", {}
|
||||||
):
|
):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
@ -62,6 +62,7 @@ class WorkspacePermissions(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class ChatPermissions(BaseModel):
|
class ChatPermissions(BaseModel):
|
||||||
|
file_upload: bool
|
||||||
delete: bool
|
delete: bool
|
||||||
edit: bool
|
edit: bool
|
||||||
temporary: bool
|
temporary: bool
|
||||||
|
@ -759,6 +759,10 @@ USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS = (
|
|||||||
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS", "False").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS", "False").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_CHAT_FILE_UPLOAD = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_CHAT_FILE_UPLOAD", "True").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
USER_PERMISSIONS_CHAT_DELETE = (
|
USER_PERMISSIONS_CHAT_DELETE = (
|
||||||
os.environ.get("USER_PERMISSIONS_CHAT_DELETE", "True").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_CHAT_DELETE", "True").lower() == "true"
|
||||||
)
|
)
|
||||||
@ -782,8 +786,9 @@ USER_PERMISSIONS = PersistentConfig(
|
|||||||
"tools": USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS,
|
"tools": USER_PERMISSIONS_WORKSPACE_TOOLS_ACCESS,
|
||||||
},
|
},
|
||||||
"chat": {
|
"chat": {
|
||||||
"deletion": USER_PERMISSIONS_CHAT_DELETE,
|
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
|
||||||
"editing": USER_PERMISSIONS_CHAT_EDIT,
|
"delete": USER_PERMISSIONS_CHAT_DELETE,
|
||||||
|
"edit": USER_PERMISSIONS_CHAT_EDIT,
|
||||||
"temporary": USER_PERMISSIONS_CHAT_TEMPORARY,
|
"temporary": USER_PERMISSIONS_CHAT_TEMPORARY,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
chat: {
|
chat: {
|
||||||
delete: true,
|
delete: true,
|
||||||
edit: true,
|
edit: true,
|
||||||
temporary: true
|
temporary: true,
|
||||||
|
file_upload: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -168,6 +169,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class=" mb-2 text-sm font-medium">{$i18n.t('Chat Permissions')}</div>
|
<div class=" mb-2 text-sm font-medium">{$i18n.t('Chat Permissions')}</div>
|
||||||
|
|
||||||
|
<div class=" flex w-full justify-between my-2 pr-2">
|
||||||
|
<div class=" self-center text-xs font-medium">
|
||||||
|
{$i18n.t('Allow File Upload')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Switch bind:state={permissions.chat.file_upload} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class=" flex w-full justify-between my-2 pr-2">
|
<div class=" flex w-full justify-between my-2 pr-2">
|
||||||
<div class=" self-center text-xs font-medium">
|
<div class=" self-center text-xs font-medium">
|
||||||
{$i18n.t('Allow Chat Delete')}
|
{$i18n.t('Allow Chat Delete')}
|
||||||
|
Loading…
Reference in New Issue
Block a user