From 582253fc68d26c1935fafce55cf3c622c13f5fbd Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 23 Dec 2024 01:37:13 -0700 Subject: [PATCH] refac --- backend/open_webui/routers/channels.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index d15a70798..9a15b0fc1 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -70,7 +70,9 @@ async def get_channel_by_id(id: str, user=Depends(get_verified_user)): status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND ) - if not has_access(user.id, type="read", access_control=channel.access_control): + if user.role != "admin" and not has_access( + user.id, type="read", access_control=channel.access_control + ): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT() ) @@ -145,7 +147,9 @@ async def get_channel_messages( status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND ) - if not has_access(user.id, type="read", access_control=channel.access_control): + if user.role != "admin" and not has_access( + user.id, type="read", access_control=channel.access_control + ): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT() ) @@ -186,7 +190,9 @@ async def post_new_message( status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND ) - if not has_access(user.id, type="read", access_control=channel.access_control): + if user.role != "admin" and not has_access( + user.id, type="read", access_control=channel.access_control + ): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT() ) @@ -236,7 +242,9 @@ async def update_message_by_id( status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND ) - if not has_access(user.id, type="read", access_control=channel.access_control): + if user.role != "admin" and not has_access( + user.id, type="read", access_control=channel.access_control + ): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT() ) @@ -294,7 +302,9 @@ async def delete_message_by_id( status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND ) - if not has_access(user.id, type="read", access_control=channel.access_control): + if user.role != "admin" and not has_access( + user.id, type="read", access_control=channel.access_control + ): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT() )