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:
guwandykandCursor committed 2026-08-24 18:24:43 +05:00
1 parent 427d5b4e07
commit 1fd0abbcb2
57 files changed
+1281 -657

No files matched your search

@@ -6,6 +6,7 @@ import (
"fmt"
"strings"
"online-back/internal/identity/rbac"
"online-back/internal/lending/loansrepayment"
"online-back/pkg/client/postgresql"
"online-back/pkg/logging"
@@ -81,6 +82,11 @@ func buildListQuery(filter loansrepayment.ListFilter) (whereClause string, args
conditions = append(conditions, fmt.Sprintf("l.passport_id ILIKE $%d", len(args)))
}
if len(filter.BranchIds) > 0 {
args = append(args, filter.BranchIds)
conditions = append(conditions, rbac.UserInBranchSQL("l.user_id", len(args)))
}
if len(conditions) == 0 {
return "", args
}