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
08c0d7a9
"...resnet50_tensorflow.git" did not exist on "e3fc61e7118333e1aca2cd59c5cf7b9c23d38107"
Commit
08c0d7a9
authored
Dec 30, 2023
by
Anuraag Jain
Browse files
fix: merge conflicts
parent
613053e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
27 deletions
+20
-27
backend/apps/web/routers/auths.py
backend/apps/web/routers/auths.py
+8
-6
backend/apps/web/routers/users.py
backend/apps/web/routers/users.py
+12
-21
No files found.
backend/apps/web/routers/auths.py
View file @
08c0d7a9
...
...
@@ -23,6 +23,7 @@ from utils.utils import (
get_password_hash
,
get_current_user
,
create_token
,
verify_auth_token
,
)
from
utils.misc
import
get_gravatar_url
from
constants
import
ERROR_MESSAGES
...
...
@@ -35,7 +36,7 @@ router = APIRouter()
############################
@
router
.
get
(
"/"
,
response_model
=
UserResponse
)
@
router
.
get
(
"/"
,
response_model
=
UserResponse
,
dependencies
=
[
Depends
(
verify_auth_token
)]
)
async
def
get_session_user
(
user
=
Depends
(
get_current_user
)):
return
{
"id"
:
user
.
id
,
...
...
@@ -51,11 +52,12 @@ async def get_session_user(user=Depends(get_current_user)):
############################
@
router
.
post
(
"/update/password"
,
response_model
=
bool
)
async
def
update_password
(
form_data
:
UpdatePasswordForm
,
cred
=
Depends
(
bearer_scheme
)):
token
=
cred
.
credentials
session_user
=
Users
.
get_user_by_token
(
token
)
@
router
.
post
(
"/update/password"
,
response_model
=
bool
,
dependencies
=
[
Depends
(
verify_auth_token
)]
)
async
def
update_password
(
form_data
:
UpdatePasswordForm
,
session_user
=
Depends
(
get_current_user
)
):
if
session_user
:
user
=
Auths
.
authenticate_user
(
session_user
.
email
,
form_data
.
password
)
...
...
backend/apps/web/routers/users.py
View file @
08c0d7a9
...
...
@@ -62,34 +62,25 @@ async def update_user_role(
@
router
.
delete
(
"/{user_id}"
,
response_model
=
bool
)
async
def
delete_user_by_id
(
user_id
:
str
,
cred
=
Depends
(
bearer_scheme
)):
token
=
cred
.
credentials
user
=
Users
.
get_user_by_token
(
token
)
if
user
:
if
user
.
role
==
"admin"
:
if
user
.
id
!=
user_id
:
result
=
Auths
.
delete_auth_by_id
(
user_id
)
if
result
:
return
True
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
detail
=
ERROR_MESSAGES
.
DELETE_USER_ERROR
,
)
async
def
delete_user_by_id
(
user_id
:
str
,
user
=
Depends
(
get_current_user
)):
if
user
.
role
==
"admin"
:
if
user
.
id
!=
user_id
:
result
=
Auths
.
delete_auth_by_id
(
user_id
)
if
result
:
return
True
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_
403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACTION_PROHIBITED
,
status_code
=
status
.
HTTP_
500_INTERNAL_SERVER_ERROR
,
detail
=
ERROR_MESSAGES
.
DELETE_USER_ERROR
,
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
AC
CESS
_PROHIBITED
,
detail
=
ERROR_MESSAGES
.
AC
TION
_PROHIBITED
,
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_40
1_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
INVALID_TOKEN
,
status_code
=
status
.
HTTP_40
3_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
)
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