MCPcopy
hub / github.com/PatchMon/PatchMon / roleRank

Function roleRank

server-source-code/internal/handler/users.go:44–59  ·  view source on GitHub ↗

roleRank returns a numeric rank for role hierarchy (higher = more privileged).

(role string)

Source from the content-addressed store, hash-verified

42
43// roleRank returns a numeric rank for role hierarchy (higher = more privileged).
44func roleRank(role string) int {
45 switch role {
46 case "superadmin":
47 return 100
48 case "admin":
49 return 90
50 case "host_manager":
51 return 50
52 case "user":
53 return 20
54 case "readonly":
55 return 10
56 default:
57 return 30 // custom roles sit mid-tier
58 }
59}
60
61// canAssignRole checks whether the calling user is allowed to assign the target role.
62func (h *UsersHandler) canAssignRole(r *http.Request, callerRole, targetRole string) bool {

Callers 4

canAssignRoleMethod · 0.85
UpdateMethod · 0.85
DeleteMethod · 0.85
ResetPasswordMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected