fix: show exam-prep catalog courses to learners when subscription gate is disabled

Align catalog list filtering with middleware so student/open-learner tokens return courses instead of an empty list while category subscription enforcement is bypassed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-06-09 00:51:15 -07:00
parent 22464479ae
commit be7946955d
3 changed files with 6 additions and 5 deletions

View File

@ -12,6 +12,9 @@ const (
SubscriptionCategoryDuolingo SubscriptionCategory = "DUOLINGO"
)
// CategorySubscriptionGateDisabled skips subscription enforcement on learner-facing routes (temporary).
var CategorySubscriptionGateDisabled = true
type DurationUnit string
const (

View File

@ -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{

View File

@ -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()
}