Bind permissions to roles and scope operator access by branch.

Replace permission_user with permission_role, enforce RBAC on admin routes, and limit operators to their assigned branches.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 18:24:43 +05:00
parent 427d5b4e07
commit 1fd0abbcb2
57 changed files with 1281 additions and 657 deletions

View File

@@ -8,6 +8,7 @@ import (
"online-back/internal/appresult"
"online-back/internal/handlers"
"online-back/internal/identity/rbac"
"online-back/internal/org/province"
"online-back/pkg/logging"
@@ -163,6 +164,9 @@ func (h *handler) getByID(c *gin.Context) {
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
return
}
if !rbac.GuardBranch(c, item.Id) {
return
}
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
}
@@ -349,5 +353,6 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
filter.UniqueCode = raw
}
rbac.BindBranchIDs(c, &filter.BranchIds)
return filter, true
}