Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
74809e73
Commit
74809e73
authored
Mar 02, 2024
by
Timothy J. Baek
Browse files
fix: user chat delete loophole
parent
a4c6a8d5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+11
-1
src/lib/apis/chats/index.ts
src/lib/apis/chats/index.ts
+1
-1
src/lib/components/chat/Settings/Chats.svelte
src/lib/components/chat/Settings/Chats.svelte
+3
-1
No files found.
backend/apps/web/routers/chats.py
View file @
74809e73
...
...
@@ -271,6 +271,16 @@ async def delete_all_chat_tags_by_id(id: str, user=Depends(get_current_user)):
@
router
.
delete
(
"/"
,
response_model
=
bool
)
async
def
delete_all_user_chats
(
user
=
Depends
(
get_current_user
)):
async
def
delete_all_user_chats
(
request
:
Request
,
user
=
Depends
(
get_current_user
)):
if
(
user
.
role
==
"user"
and
not
request
.
app
.
state
.
USER_PERMISSIONS
[
"chat"
][
"deletion"
]
):
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
)
result
=
Chats
.
delete_chats_by_user_id
(
user
.
id
)
return
result
src/lib/apis/chats/index.ts
View file @
74809e73
...
...
@@ -439,7 +439,7 @@ export const deleteAllChats = async (token: string) => {
return
json
;
})
.
catch
((
err
)
=>
{
error
=
err
;
error
=
err
.
detail
;
console
.
log
(
err
);
return
null
;
...
...
src/lib/components/chat/Settings/Chats.svelte
View file @
74809e73
...
...
@@ -75,7 +75,9 @@
const deleteChats = async () => {
await goto('/');
await deleteAllChats(localStorage.token);
await deleteAllChats(localStorage.token).catch((error) => {
toast.error(error);
});
await chats.set(await getChatList(localStorage.token));
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment