diff --git a/internal/domain/subscriptions.go b/internal/domain/subscriptions.go index 680a101..740aea1 100644 --- a/internal/domain/subscriptions.go +++ b/internal/domain/subscriptions.go @@ -12,6 +12,9 @@ const ( SubscriptionCategoryDuolingo SubscriptionCategory = "DUOLINGO" ) +// CategorySubscriptionGateDisabled skips subscription enforcement on learner-facing routes (temporary). +var CategorySubscriptionGateDisabled = true + type DurationUnit string const ( diff --git a/internal/web_server/handlers/exam_prep_catalog_course_handler.go b/internal/web_server/handlers/exam_prep_catalog_course_handler.go index 38a8147..93b9c54 100644 --- a/internal/web_server/handlers/exam_prep_catalog_course_handler.go +++ b/internal/web_server/handlers/exam_prep_catalog_course_handler.go @@ -61,7 +61,7 @@ func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error { offset, _ := strconv.Atoi(c.Query("offset", "0")) role, _ := c.Locals("role").(domain.Role) - if role == domain.RoleStudent || role == domain.RoleOpenLearner { + if role.IsCustomerLearnerRole() && !domain.CategorySubscriptionGateDisabled { userID, ok := c.Locals("user_id").(int64) if !ok || userID == 0 { return c.Status(fiber.StatusUnauthorized).JSON(domain.ErrorResponse{ diff --git a/internal/web_server/middleware.go b/internal/web_server/middleware.go index dd29806..9d56813 100644 --- a/internal/web_server/middleware.go +++ b/internal/web_server/middleware.go @@ -15,8 +15,6 @@ import ( "go.uber.org/zap" ) -var categorySubscriptionGateDisabled = true - func (a *App) authMiddleware(c *fiber.Ctx) error { ip := c.IP() userAgent := c.Get("User-Agent") @@ -226,7 +224,7 @@ func (a *App) RequireSubscriptionCategory(category domain.SubscriptionCategory) if role != domain.RoleStudent && role != domain.RoleOpenLearner { return c.Next() } - if categorySubscriptionGateDisabled { + if domain.CategorySubscriptionGateDisabled { return c.Next() } active, err := a.subscriptionsSvc.HasActiveSubscriptionByCategory(c.Context(), userID, category) @@ -259,7 +257,7 @@ func (a *App) RequireExamPrepSubscription() fiber.Handler { if role != domain.RoleStudent && role != domain.RoleOpenLearner { return c.Next() } - if categorySubscriptionGateDisabled { + if domain.CategorySubscriptionGateDisabled { return c.Next() }