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
ad1cb5fc
Commit
ad1cb5fc
authored
Dec 28, 2023
by
Timothy J. Baek
Browse files
fix: disable admin self user delete
parent
b61bb779
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
backend/apps/web/routers/users.py
backend/apps/web/routers/users.py
+11
-5
No files found.
backend/apps/web/routers/users.py
View file @
ad1cb5fc
...
@@ -87,15 +87,21 @@ async def delete_user_by_id(user_id: str, cred=Depends(bearer_scheme)):
...
@@ -87,15 +87,21 @@ async def delete_user_by_id(user_id: str, cred=Depends(bearer_scheme)):
if
user
:
if
user
:
if
user
.
role
==
"admin"
:
if
user
.
role
==
"admin"
:
if
user
.
id
!=
user_id
:
result
=
Users
.
delete_user_by_id
(
user_id
)
result
=
Users
.
delete_user_by_id
(
user_id
)
if
result
:
if
result
:
return
True
return
True
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_
403_FORBIDDEN
,
status_code
=
status
.
HTTP_
500_INTERNAL_SERVER_ERROR
,
detail
=
ERROR_MESSAGES
.
DELETE_USER_ERROR
,
detail
=
ERROR_MESSAGES
.
DELETE_USER_ERROR
,
)
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACTION_PROHIBITED
,
)
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
status_code
=
status
.
HTTP_403_FORBIDDEN
,
...
...
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