Merge pull request #8470 from tarmst/add-read-write-toggle-to-access-control

feat: Add toggle to read/write perms on access control
This commit is contained in:
Timothy Jaeryang Baek
2025-01-13 21:22:36 -08:00
committed by GitHub
5 changed files with 39 additions and 7 deletions

View File

@@ -213,8 +213,8 @@ async def update_knowledge_by_id(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.NOT_FOUND,
)
if knowledge.user_id != user.id and user.role != "admin":
# Is the user the original creator, in a group with write access, or an admin
if knowledge.user_id != user.id and not has_access(user.id, "write", knowledge.access_control) and user.role != "admin":
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,

View File

@@ -111,8 +111,9 @@ async def update_prompt_by_command(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.NOT_FOUND,
)
if prompt.user_id != user.id and user.role != "admin":
# Is the user the original creator, in a group with write access, or an admin
if prompt.user_id != user.id and not has_access(user.id, "write", prompt.access_control) and user.role != "admin":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,

View File

@@ -165,7 +165,8 @@ async def update_tools_by_id(
detail=ERROR_MESSAGES.NOT_FOUND,
)
if tools.user_id != user.id and user.role != "admin":
# Is the user the original creator, in a group with write access, or an admin
if tools.user_id != user.id and not has_access(user.id, "write", tools.access_control) and user.role != "admin":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.UNAUTHORIZED,