RezinaLMS-BackEnd/internal/domain/role.go
Yared Yemane df4f4d8ade Limit staff team roles to Super Admin, Admin, and Content Manager.
Add CONTENT_MANAGER RBAC defaults, migration, and Super Admin-only team email invitations; restrict assignable team_member roles without changing platform user roles.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 12:01:02 +03:00

56 lines
1.7 KiB
Go

package domain
type Role string
const (
RoleSuperAdmin Role = "SUPER_ADMIN"
RoleAdmin Role = "ADMIN"
RoleContentManager Role = "CONTENT_MANAGER"
RoleStudent Role = "STUDENT"
// RoleOpenLearner can consume LMS (Learn English) and exam-prep content without
// sequential/precedence locks or subscription gates (including premium tiers).
RoleOpenLearner Role = "OPEN_LEARNER"
RoleInstructor Role = "INSTRUCTOR"
RoleSupport Role = "SUPPORT"
)
func (r Role) IsValid() bool {
switch r {
case RoleSuperAdmin, RoleAdmin, RoleContentManager, RoleStudent, RoleOpenLearner, RoleInstructor, RoleSupport:
return true
default:
return false
}
}
// UsesLMSSequentialGating is true when Learn English (LMS) APIs apply sequential prerequisite locks (403 when blocked).
// Exam-prep does not use this — see UsesExamPrepSequentialGating.
func (r Role) UsesLMSSequentialGating() bool {
return r == RoleStudent
}
// UsesExamPrepSequentialGating is true when exam-prep APIs apply precedence / practice-order locks.
// Currently disabled for all roles: STUDENT access is subscription/tier only; OPEN_LEARNER already bypasses gates.
func (r Role) UsesExamPrepSequentialGating() bool {
return false
}
// IsCustomerLearnerRole is true for platform roles that sign in as customers and consume learner-facing LMS APIs.
func (r Role) IsCustomerLearnerRole() bool {
return r == RoleStudent || r == RoleOpenLearner
}
// BypassesSubscription is true when subscription middleware must not block access.
func (r Role) BypassesSubscription() bool {
switch r {
case RoleSuperAdmin, RoleAdmin, RoleContentManager, RoleInstructor, RoleSupport, RoleOpenLearner:
return true
default:
return false
}
}
func (r Role) Value() string {
return string(r)
}