Ensure OPEN_LEARNER bypasses subscription and sequential content locks.

Harden LMS and exam-prep gates so only STUDENT is enforced, and return FREE effective_access_tier for OPEN_LEARNER so clients do not show paywall locks.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-07-14 02:38:00 -07:00
parent 342b10a35a
commit 6b02a5a1fc
15 changed files with 129 additions and 63 deletions

View File

@ -43,3 +43,12 @@ func EffectiveContentAccessTier(tiers ...ContentAccessTier) ContentAccessTier {
func (t ContentAccessTier) RequiresSubscription() bool {
return t == ContentAccessPremium
}
// ContentAccessTierForRole returns the tier shown to a caller.
// OPEN_LEARNER always sees FREE so clients do not apply paywall/lock UI.
func ContentAccessTierForRole(role Role, tier ContentAccessTier) ContentAccessTier {
if role == RoleOpenLearner {
return ContentAccessFree
}
return tier
}

View File

@ -13,3 +13,12 @@ func TestEffectiveContentAccessTier(t *testing.T) {
t.Fatalf("expected cascaded PREMIUM, got %s", got)
}
}
func TestContentAccessTierForRole_openLearnerAlwaysFree(t *testing.T) {
if got := ContentAccessTierForRole(RoleOpenLearner, ContentAccessPremium); got != ContentAccessFree {
t.Fatalf("OPEN_LEARNER expected FREE, got %s", got)
}
if got := ContentAccessTierForRole(RoleStudent, ContentAccessPremium); got != ContentAccessPremium {
t.Fatalf("STUDENT expected PREMIUM, got %s", got)
}
}

View File

@ -6,7 +6,8 @@ const (
RoleSuperAdmin Role = "SUPER_ADMIN"
RoleAdmin Role = "ADMIN"
RoleStudent Role = "STUDENT"
// RoleOpenLearner can consume LMS and exam-prep content without sequential locks or subscription gates.
// 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"

View File

@ -0,0 +1,26 @@
package domain
import "testing"
func TestRoleOpenLearnerBypassesSubscriptionAndSequentialLocks(t *testing.T) {
role := RoleOpenLearner
if !role.BypassesSubscription() {
t.Fatal("OPEN_LEARNER must bypass subscription gates")
}
if role.UsesLMSSequentialGating() {
t.Fatal("OPEN_LEARNER must not use sequential / precedence locking")
}
if !role.IsCustomerLearnerRole() {
t.Fatal("OPEN_LEARNER should be a customer learner role")
}
}
func TestRoleStudentKeepsSubscriptionAndSequentialLocks(t *testing.T) {
role := RoleStudent
if role.BypassesSubscription() {
t.Fatal("STUDENT must not bypass subscription gates")
}
if !role.UsesLMSSequentialGating() {
t.Fatal("STUDENT must use sequential / precedence locking")
}
}

View File

@ -31,7 +31,8 @@ func (a *App) RequireLMSSubscriptionUnlessFree() fiber.Handler {
if bypassSubscriptionForRole(role) {
return c.Next()
}
if role != domain.RoleStudent && role != domain.RoleOpenLearner {
// Only STUDENT is subject to LMS subscription enforcement.
if role != domain.RoleStudent {
return c.Next()
}
if domain.CategorySubscriptionGateDisabled {

View File

@ -33,57 +33,75 @@ func (h *Handler) blockLearnerIfNotLMSProgram(c *fiber.Ctx, program domain.Progr
return nil
}
func applyProgramEffectiveAccessTier(p *domain.Program) {
p.EffectiveAccessTier = p.AccessTier
func applyProgramEffectiveAccessTier(p *domain.Program, role domain.Role) {
p.EffectiveAccessTier = domain.ContentAccessTierForRole(role, p.AccessTier)
}
func applyCourseEffectiveAccessTier(course *domain.Course, program domain.Program) {
course.EffectiveAccessTier = domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier)
func applyCourseEffectiveAccessTier(course *domain.Course, program domain.Program, role domain.Role) {
course.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier),
)
}
func applyModuleEffectiveAccessTier(module *domain.Module, program domain.Program, course domain.Course) {
module.EffectiveAccessTier = domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier, module.AccessTier)
func applyModuleEffectiveAccessTier(module *domain.Module, program domain.Program, course domain.Course, role domain.Role) {
module.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier, module.AccessTier),
)
}
func applyLessonEffectiveAccessTier(lesson *domain.Lesson, program domain.Program, course domain.Course, module domain.Module) {
lesson.EffectiveAccessTier = domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier, module.AccessTier, lesson.AccessTier)
func applyLessonEffectiveAccessTier(lesson *domain.Lesson, program domain.Program, course domain.Course, module domain.Module, role domain.Role) {
lesson.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(program.AccessTier, course.AccessTier, module.AccessTier, lesson.AccessTier),
)
}
func applyExamPrepCatalogCourseEffectiveAccessTier(cc *domain.ExamPrepCatalogCourse) {
cc.EffectiveAccessTier = cc.AccessTier
func applyExamPrepCatalogCourseEffectiveAccessTier(cc *domain.ExamPrepCatalogCourse, role domain.Role) {
cc.EffectiveAccessTier = domain.ContentAccessTierForRole(role, cc.AccessTier)
}
func applyExamPrepUnitEffectiveAccessTier(unit *domain.ExamPrepUnit, catalogCourse domain.ExamPrepCatalogCourse) {
unit.EffectiveAccessTier = domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier)
func applyExamPrepUnitEffectiveAccessTier(unit *domain.ExamPrepUnit, catalogCourse domain.ExamPrepCatalogCourse, role domain.Role) {
unit.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier),
)
}
func applyExamPrepModuleEffectiveAccessTier(module *domain.ExamPrepModule, catalogCourse domain.ExamPrepCatalogCourse, unit domain.ExamPrepUnit) {
module.EffectiveAccessTier = domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier, module.AccessTier)
func applyExamPrepModuleEffectiveAccessTier(module *domain.ExamPrepModule, catalogCourse domain.ExamPrepCatalogCourse, unit domain.ExamPrepUnit, role domain.Role) {
module.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier, module.AccessTier),
)
}
func applyExamPrepLessonEffectiveAccessTier(lesson *domain.ExamPrepLesson, catalogCourse domain.ExamPrepCatalogCourse, unit domain.ExamPrepUnit, module domain.ExamPrepModule) {
lesson.EffectiveAccessTier = domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier, module.AccessTier, lesson.AccessTier)
func applyExamPrepLessonEffectiveAccessTier(lesson *domain.ExamPrepLesson, catalogCourse domain.ExamPrepCatalogCourse, unit domain.ExamPrepUnit, module domain.ExamPrepModule, role domain.Role) {
lesson.EffectiveAccessTier = domain.ContentAccessTierForRole(
role,
domain.EffectiveContentAccessTier(catalogCourse.AccessTier, unit.AccessTier, module.AccessTier, lesson.AccessTier),
)
}
func annotateProgramsEffectiveAccessTier(items []domain.Program) {
func annotateProgramsEffectiveAccessTier(role domain.Role, items []domain.Program) {
for i := range items {
applyProgramEffectiveAccessTier(&items[i])
applyProgramEffectiveAccessTier(&items[i], role)
}
}
func annotateCoursesEffectiveAccessTier(items []domain.Course, program domain.Program) {
func annotateCoursesEffectiveAccessTier(role domain.Role, items []domain.Course, program domain.Program) {
for i := range items {
applyCourseEffectiveAccessTier(&items[i], program)
applyCourseEffectiveAccessTier(&items[i], program, role)
}
}
func annotateExamPrepCatalogCoursesEffectiveAccessTier(items []domain.ExamPrepCatalogCourse) {
func annotateExamPrepCatalogCoursesEffectiveAccessTier(role domain.Role, items []domain.ExamPrepCatalogCourse) {
for i := range items {
applyExamPrepCatalogCourseEffectiveAccessTier(&items[i])
applyExamPrepCatalogCourseEffectiveAccessTier(&items[i], role)
}
}
func (h *Handler) annotateLMSModulesEffectiveAccessTier(ctx context.Context, courseID int64, items []domain.Module) error {
func (h *Handler) annotateLMSModulesEffectiveAccessTier(ctx context.Context, role domain.Role, courseID int64, items []domain.Module) error {
course, err := h.courseSvc.GetByID(ctx, courseID)
if err != nil {
return err
@ -93,12 +111,12 @@ func (h *Handler) annotateLMSModulesEffectiveAccessTier(ctx context.Context, cou
return err
}
for i := range items {
applyModuleEffectiveAccessTier(&items[i], program, course)
applyModuleEffectiveAccessTier(&items[i], program, course, role)
}
return nil
}
func (h *Handler) annotateLMSModuleEffectiveAccessTier(ctx context.Context, module *domain.Module) error {
func (h *Handler) annotateLMSModuleEffectiveAccessTier(ctx context.Context, role domain.Role, module *domain.Module) error {
course, err := h.courseSvc.GetByID(ctx, module.CourseID)
if err != nil {
return err
@ -107,11 +125,11 @@ func (h *Handler) annotateLMSModuleEffectiveAccessTier(ctx context.Context, modu
if err != nil {
return err
}
applyModuleEffectiveAccessTier(module, program, course)
applyModuleEffectiveAccessTier(module, program, course, role)
return nil
}
func (h *Handler) annotateLMSLessonsEffectiveAccessTier(ctx context.Context, moduleID int64, items []domain.Lesson) error {
func (h *Handler) annotateLMSLessonsEffectiveAccessTier(ctx context.Context, role domain.Role, moduleID int64, items []domain.Lesson) error {
module, err := h.moduleSvc.GetByID(ctx, moduleID)
if err != nil {
return err
@ -125,12 +143,12 @@ func (h *Handler) annotateLMSLessonsEffectiveAccessTier(ctx context.Context, mod
return err
}
for i := range items {
applyLessonEffectiveAccessTier(&items[i], program, course, module)
applyLessonEffectiveAccessTier(&items[i], program, course, module, role)
}
return nil
}
func (h *Handler) annotateLMSLessonEffectiveAccessTier(ctx context.Context, lesson *domain.Lesson) error {
func (h *Handler) annotateLMSLessonEffectiveAccessTier(ctx context.Context, role domain.Role, lesson *domain.Lesson) error {
module, err := h.moduleSvc.GetByID(ctx, lesson.ModuleID)
if err != nil {
return err
@ -143,31 +161,31 @@ func (h *Handler) annotateLMSLessonEffectiveAccessTier(ctx context.Context, less
if err != nil {
return err
}
applyLessonEffectiveAccessTier(lesson, program, course, module)
applyLessonEffectiveAccessTier(lesson, program, course, module, role)
return nil
}
func (h *Handler) annotateExamPrepUnitsEffectiveAccessTier(ctx context.Context, catalogCourseID int64, items []domain.ExamPrepUnit) error {
func (h *Handler) annotateExamPrepUnitsEffectiveAccessTier(ctx context.Context, role domain.Role, catalogCourseID int64, items []domain.ExamPrepUnit) error {
cc, err := h.examPrepSvc.GetCatalogCourseByID(ctx, catalogCourseID)
if err != nil {
return err
}
for i := range items {
applyExamPrepUnitEffectiveAccessTier(&items[i], cc)
applyExamPrepUnitEffectiveAccessTier(&items[i], cc, role)
}
return nil
}
func (h *Handler) annotateExamPrepUnitEffectiveAccessTier(ctx context.Context, unit *domain.ExamPrepUnit) error {
func (h *Handler) annotateExamPrepUnitEffectiveAccessTier(ctx context.Context, role domain.Role, unit *domain.ExamPrepUnit) error {
cc, err := h.examPrepSvc.GetCatalogCourseByID(ctx, unit.CatalogCourseID)
if err != nil {
return err
}
applyExamPrepUnitEffectiveAccessTier(unit, cc)
applyExamPrepUnitEffectiveAccessTier(unit, cc, role)
return nil
}
func (h *Handler) annotateExamPrepModulesEffectiveAccessTier(ctx context.Context, unitID int64, items []domain.ExamPrepModule) error {
func (h *Handler) annotateExamPrepModulesEffectiveAccessTier(ctx context.Context, role domain.Role, unitID int64, items []domain.ExamPrepModule) error {
unit, err := h.examPrepSvc.GetUnitByID(ctx, unitID)
if err != nil {
return err
@ -177,12 +195,12 @@ func (h *Handler) annotateExamPrepModulesEffectiveAccessTier(ctx context.Context
return err
}
for i := range items {
applyExamPrepModuleEffectiveAccessTier(&items[i], cc, unit)
applyExamPrepModuleEffectiveAccessTier(&items[i], cc, unit, role)
}
return nil
}
func (h *Handler) annotateExamPrepModuleEffectiveAccessTier(ctx context.Context, module *domain.ExamPrepModule) error {
func (h *Handler) annotateExamPrepModuleEffectiveAccessTier(ctx context.Context, role domain.Role, module *domain.ExamPrepModule) error {
unit, err := h.examPrepSvc.GetUnitByID(ctx, module.UnitID)
if err != nil {
return err
@ -191,11 +209,11 @@ func (h *Handler) annotateExamPrepModuleEffectiveAccessTier(ctx context.Context,
if err != nil {
return err
}
applyExamPrepModuleEffectiveAccessTier(module, cc, unit)
applyExamPrepModuleEffectiveAccessTier(module, cc, unit, role)
return nil
}
func (h *Handler) annotateExamPrepLessonsEffectiveAccessTier(ctx context.Context, moduleID int64, items []domain.ExamPrepLesson) error {
func (h *Handler) annotateExamPrepLessonsEffectiveAccessTier(ctx context.Context, role domain.Role, moduleID int64, items []domain.ExamPrepLesson) error {
module, err := h.examPrepSvc.GetModuleByID(ctx, moduleID)
if err != nil {
return err
@ -209,12 +227,12 @@ func (h *Handler) annotateExamPrepLessonsEffectiveAccessTier(ctx context.Context
return err
}
for i := range items {
applyExamPrepLessonEffectiveAccessTier(&items[i], cc, unit, module)
applyExamPrepLessonEffectiveAccessTier(&items[i], cc, unit, module, role)
}
return nil
}
func (h *Handler) annotateExamPrepLessonEffectiveAccessTier(ctx context.Context, lesson *domain.ExamPrepLesson) error {
func (h *Handler) annotateExamPrepLessonEffectiveAccessTier(ctx context.Context, role domain.Role, lesson *domain.ExamPrepLesson) error {
module, err := h.examPrepSvc.GetModuleByID(ctx, lesson.UnitModuleID)
if err != nil {
return err
@ -227,7 +245,7 @@ func (h *Handler) annotateExamPrepLessonEffectiveAccessTier(ctx context.Context,
if err != nil {
return err
}
applyExamPrepLessonEffectiveAccessTier(lesson, cc, unit, module)
applyExamPrepLessonEffectiveAccessTier(lesson, cc, unit, module, role)
return nil
}

View File

@ -151,7 +151,7 @@ func (h *Handler) ListCoursesByProgram(c *fiber.Ctx) error {
}
program = p
}
annotateCoursesEffectiveAccessTier(items, program)
annotateCoursesEffectiveAccessTier(role, items, program)
}
uid := c.Locals("user_id").(int64)
for i := range items {
@ -226,9 +226,9 @@ func (h *Handler) GetCourse(c *fiber.Ctx) error {
if err := h.blockLearnerIfNotLMSProgram(c, p); err != nil {
return err
}
applyCourseEffectiveAccessTier(&course, p)
uid := c.Locals("user_id").(int64)
role := c.Locals("role").(domain.Role)
applyCourseEffectiveAccessTier(&course, p, role)
uid := c.Locals("user_id").(int64)
if err := h.lmsProgressSvc.ApplyAccessCourse(c.Context(), role, uid, &course); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
Message: "Failed to evaluate course access",

View File

@ -70,7 +70,7 @@ func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error {
Error: err.Error(),
})
}
annotateExamPrepCatalogCoursesEffectiveAccessTier(items)
annotateExamPrepCatalogCoursesEffectiveAccessTier(c.Locals("role").(domain.Role), items)
if err := h.applyExamPrepAccessCatalogCourses(c.Context(), c, items); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
Message: "Failed to build catalog course list",
@ -165,7 +165,7 @@ func (h *Handler) GetExamPrepCatalogCourseByID(c *fiber.Ctx) error {
Error: examprep.ErrCatalogCourseNotFound.Error(),
})
}
applyExamPrepCatalogCourseEffectiveAccessTier(&out)
applyExamPrepCatalogCourseEffectiveAccessTier(&out, c.Locals("role").(domain.Role))
if err := h.applyExamPrepAccessCatalogCourse(c.Context(), c, &out); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
Message: "Failed to build catalog course",

View File

@ -100,7 +100,7 @@ func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error {
Error: err.Error(),
})
}
if err := h.annotateExamPrepLessonsEffectiveAccessTier(c.Context(), moduleID, items); err != nil {
if err := h.annotateExamPrepLessonsEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), moduleID, items); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}
@ -206,7 +206,7 @@ func (h *Handler) GetExamPrepLessonByID(c *fiber.Ctx) error {
Error: examprep.ErrLessonNotFound.Error(),
})
}
if err := h.annotateExamPrepLessonEffectiveAccessTier(c.Context(), &les); err != nil {
if err := h.annotateExamPrepLessonEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), &les); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}

View File

@ -98,7 +98,7 @@ func (h *Handler) ListExamPrepModulesByUnit(c *fiber.Ctx) error {
Error: err.Error(),
})
}
if err := h.annotateExamPrepModulesEffectiveAccessTier(c.Context(), unitID, items); err != nil {
if err := h.annotateExamPrepModulesEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), unitID, items); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}
@ -206,7 +206,7 @@ func (h *Handler) GetExamPrepModuleByID(c *fiber.Ctx) error {
Error: examprep.ErrModuleNotFound.Error(),
})
}
if err := h.annotateExamPrepModuleEffectiveAccessTier(c.Context(), &out); err != nil {
if err := h.annotateExamPrepModuleEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), &out); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}

View File

@ -105,7 +105,7 @@ func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error {
Error: err.Error(),
})
}
if err := h.annotateExamPrepUnitsEffectiveAccessTier(c.Context(), catalogCourseID, items); err != nil {
if err := h.annotateExamPrepUnitsEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), catalogCourseID, items); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}
@ -214,7 +214,7 @@ func (h *Handler) GetExamPrepUnitByID(c *fiber.Ctx) error {
Error: examprep.ErrUnitNotFound.Error(),
})
}
if err := h.annotateExamPrepUnitEffectiveAccessTier(c.Context(), &out); err != nil {
if err := h.annotateExamPrepUnitEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), &out); err != nil {
if status, msg := mapExamPrepEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}

View File

@ -99,7 +99,7 @@ func (h *Handler) ListLessonsByModule(c *fiber.Ctx) error {
Error: err.Error(),
})
}
if err := h.annotateLMSLessonsEffectiveAccessTier(c.Context(), moduleID, items); err != nil {
if err := h.annotateLMSLessonsEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), moduleID, items); err != nil {
if status, msg := mapLMSEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}
@ -158,7 +158,7 @@ func (h *Handler) GetLesson(c *fiber.Ctx) error {
Error: lessons.ErrLessonNotFound.Error(),
})
}
if err := h.annotateLMSLessonEffectiveAccessTier(c.Context(), &les); err != nil {
if err := h.annotateLMSLessonEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), &les); err != nil {
if status, msg := mapLMSEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}

View File

@ -114,7 +114,7 @@ func (h *Handler) ListModulesByCourse(c *fiber.Ctx) error {
Error: err.Error(),
})
}
if err := h.annotateLMSModulesEffectiveAccessTier(c.Context(), courseID, items); err != nil {
if err := h.annotateLMSModulesEffectiveAccessTier(c.Context(), c.Locals("role").(domain.Role), courseID, items); err != nil {
if status, msg := mapLMSEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}
@ -176,7 +176,7 @@ func (h *Handler) GetModule(c *fiber.Ctx) error {
}
uid := c.Locals("user_id").(int64)
role := c.Locals("role").(domain.Role)
if err := h.annotateLMSModuleEffectiveAccessTier(c.Context(), &mod); err != nil {
if err := h.annotateLMSModuleEffectiveAccessTier(c.Context(), role, &mod); err != nil {
if status, msg := mapLMSEffectiveAccessTierError(err); status != 0 {
return c.Status(status).JSON(domain.ErrorResponse{Message: msg, Error: err.Error()})
}

View File

@ -82,7 +82,7 @@ func (h *Handler) ListPrograms(c *fiber.Ctx) error {
Error: err.Error(),
})
}
annotateProgramsEffectiveAccessTier(items)
annotateProgramsEffectiveAccessTier(role, items)
uid := c.Locals("user_id").(int64)
for i := range items {
if err := h.lmsProgressSvc.ApplyAccessProgram(c.Context(), role, uid, &items[i]); err != nil {
@ -143,7 +143,7 @@ func (h *Handler) GetProgram(c *fiber.Ctx) error {
if err := h.blockLearnerIfNotLMSProgram(c, p); err != nil {
return err
}
applyProgramEffectiveAccessTier(&p)
applyProgramEffectiveAccessTier(&p, c.Locals("role").(domain.Role))
uid := c.Locals("user_id").(int64)
role := c.Locals("role").(domain.Role)
if err := h.lmsProgressSvc.ApplyAccessProgram(c.Context(), role, uid, &p); err != nil {

View File

@ -224,7 +224,8 @@ func (a *App) RequireSubscriptionCategory(category domain.SubscriptionCategory)
if bypassSubscriptionForRole(role) {
return c.Next()
}
if role != domain.RoleStudent && role != domain.RoleOpenLearner {
// Only STUDENT is subject to category subscription enforcement.
if role != domain.RoleStudent {
return c.Next()
}
if domain.CategorySubscriptionGateDisabled {
@ -260,7 +261,8 @@ func (a *App) RequireExamPrepSubscription() fiber.Handler {
if bypassSubscriptionForRole(role) {
return c.Next()
}
if role != domain.RoleStudent && role != domain.RoleOpenLearner {
// Only STUDENT is subject to exam-prep subscription enforcement.
if role != domain.RoleStudent {
return c.Next()
}
if domain.CategorySubscriptionGateDisabled || domain.ExamPrepSubscriptionGateDisabled {