Timothy Jaeryang Baek 4 months ago
parent
commit
00e4391a6f
1 changed files with 9 additions and 6 deletions
  1. 9 6
      backend/open_webui/routers/notes.py

+ 9 - 6
backend/open_webui/routers/notes.py

@@ -124,8 +124,9 @@ async def get_note_by_id(request: Request, id: str, user=Depends(get_verified_us
             status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
         )
 
-    if (user.role != "admin" and user.id != note.user_id) or (
-        not has_access(user.id, type="read", access_control=note.access_control)
+    if user.role != "admin" or (
+        user.id != note.user_id
+        and not has_access(user.id, type="read", access_control=note.access_control)
     ):
         raise HTTPException(
             status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
@@ -157,8 +158,9 @@ async def update_note_by_id(
             status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
         )
 
-    if (user.role != "admin" and user.id != note.user_id) or (
-        not has_access(user.id, type="write", access_control=note.access_control)
+    if user.role != "admin" or (
+        user.id != note.user_id
+        and not has_access(user.id, type="write", access_control=note.access_control)
     ):
         raise HTTPException(
             status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()
@@ -195,8 +197,9 @@ async def delete_note_by_id(request: Request, id: str, user=Depends(get_verified
             status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND
         )
 
-    if (user.role != "admin" and user.id != note.user_id) or (
-        not has_access(user.id, type="write", access_control=note.access_control)
+    if user.role != "admin" or (
+        user.id != note.user_id
+        and not has_access(user.id, type="write", access_control=note.access_control)
     ):
         raise HTTPException(
             status_code=status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.DEFAULT()