fix: don't allow sharing admins to change own role (#21634)

resolve coder/internal#1280
This commit is contained in:
Jaayden Halko
2026-01-30 18:27:30 +07:00
committed by GitHub
parent a464ab67c6
commit 4847920407
2 changed files with 76 additions and 0 deletions
+8
View File
@@ -2353,6 +2353,14 @@ func (api *API) patchWorkspaceACL(rw http.ResponseWriter, r *http.Request) {
return
}
apiKey := httpmw.APIKey(r)
if _, ok := req.UserRoles[apiKey.UserID.String()]; ok {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "You cannot change your own workspace sharing role.",
})
return
}
validErrs := acl.Validate(ctx, api.Database, WorkspaceACLUpdateValidator(req))
if len(validErrs) > 0 {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{