Skip to content

Commit 373cded

Browse files
committed
Runtime-disable foundation subscription routes (can be enabled in config)
1 parent b5b9f61 commit 373cded

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/config/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ type AdminConfig struct {
123123
}
124124

125125
type DevConfig struct {
126-
LiveTemplates bool // load templates live from the filesystem instead of embedding them
126+
LiveTemplates bool // load templates live from the filesystem instead of embedding them
127+
MembershipsActive bool // Temporary! Remove when shipping HSF memberships.
127128
}
128129

129130
type PreviewGenerationConfig struct {
@@ -139,7 +140,6 @@ type PostmarkConfig struct {
139140
TransactionalStreamToken string
140141
}
141142

142-
143143
func init() {
144144
if Config.EpisodeGuide.Projects == nil {
145145
Config.EpisodeGuide.Projects = make(map[string]string)

src/website/routes.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"git.handmade.network/hmn/hmn/src/buildcss"
15+
"git.handmade.network/hmn/hmn/src/config"
1516
"git.handmade.network/hmn/hmn/src/db"
1617
"git.handmade.network/hmn/hmn/src/email"
1718
"git.handmade.network/hmn/hmn/src/hmndata"
@@ -46,8 +47,14 @@ func NewWebsiteRoutes(conn *pgxpool.Pool, perfCollector *perf.PerfCollector) htt
4647
redirectToHMN,
4748
)
4849
apiRoutes := routes.WithMiddleware(panicCatcherMiddleware(true))
49-
50-
50+
hsfMembershipRoutes := hmnOnly.WithMiddleware(func(h Handler) Handler {
51+
return func(c *RequestContext) ResponseData {
52+
if !config.Config.DevConfig.MembershipsActive {
53+
return FourOhFour(c)
54+
}
55+
return h(c)
56+
}
57+
})
5158

5259
routes.GET(hmnurl.RegexEsBuild, func(c *RequestContext) ResponseData {
5360
if buildcss.ActiveServerPort != 0 {
@@ -215,10 +222,10 @@ func NewWebsiteRoutes(conn *pgxpool.Pool, perfCollector *perf.PerfCollector) htt
215222
hmnOnly.GET(hmnurl.RegexUserSettings, needsAuth(UserSettings))
216223
hmnOnly.POST(hmnurl.RegexUserSettings, needsAuth(csrfMiddleware(UserSettingsSave)))
217224

218-
hmnOnly.GET(hmnurl.RegexSubscriptionManage, needsAuth(SubscriptionManage))
219-
hmnOnly.POST(hmnurl.RegexSubscriptionSubscribe, needsAuth(csrfMiddleware(SubscriptionSubscribe)))
220-
hmnOnly.POST(hmnurl.RegexSubscriptionCancel, needsAuth(csrfMiddleware(SubscriptionCancel)))
221-
hmnOnly.POST(hmnurl.RegexSubscriptionResume, needsAuth(csrfMiddleware(SubscriptionResume)))
225+
hsfMembershipRoutes.GET(hmnurl.RegexSubscriptionManage, needsAuth(SubscriptionManage))
226+
hsfMembershipRoutes.POST(hmnurl.RegexSubscriptionSubscribe, needsAuth(csrfMiddleware(SubscriptionSubscribe)))
227+
hsfMembershipRoutes.POST(hmnurl.RegexSubscriptionCancel, needsAuth(csrfMiddleware(SubscriptionCancel)))
228+
hsfMembershipRoutes.POST(hmnurl.RegexSubscriptionResume, needsAuth(csrfMiddleware(SubscriptionResume)))
222229

223230
hmnOnly.GET(hmnurl.RegexPersonalBlog, BlogPersonalIndex)
224231
hmnOnly.GET(hmnurl.RegexPersonalBlogThread, BlogPersonalThread)

0 commit comments

Comments
 (0)