Vendor SharedCode locally
Docker / Docker Build & Push (push) Failing after 1m19s
Lint / Lint (push) Successful in 15s
Tests / Go backend (push) Successful in 19s
Tests / Dashboard checks (push) Successful in 18s

This commit is contained in:
Gabriel20xx committed 2026-08-06 15:52:56 +02:00
1 parent a8c51b8484
commit 6eb8f4ad60
88 files changed
+9708 -275

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package auth
// Role is the shared account-management role used by the web applications.
type Role string
const (
RoleSuperAdmin Role = "superadmin"
RoleAdmin Role = "admin"
RoleUser Role = "user"
)
// NormalizeRole keeps persisted role values inside the shared contract.
func NormalizeRole(value string) Role {
switch Role(value) {
case RoleSuperAdmin:
return RoleSuperAdmin
case RoleAdmin:
return RoleAdmin
default:
return RoleUser
}
}
// CanManageUsers is the common authorization gate for account CRUD.
func CanManageUsers(role string) bool {
role = string(NormalizeRole(role))
return role == string(RoleSuperAdmin) || role == string(RoleAdmin)
}
// CanAssignRole prevents an administrator from creating or promoting another
// administrator. Only the first-created superadmin can delegate admin access.
func CanAssignRole(actorRole, targetRole string) bool {
return NormalizeRole(actorRole) == RoleSuperAdmin && NormalizeRole(targetRole) != RoleSuperAdmin
}