-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
Follow-up to PR #47 (resolves #31). Refactor the applications enabled toggle to use a middleware pattern, consistent with how AdminScheduleEditPermissionMiddleware gates schedule mutations.
Context
PR #47 introduced GET /v1/applications/enabled and POST /v1/superadmin/settings/applications-enabled to allow superadmins to toggle whether hackers can submit applications. Currently, the toggle exists but is not enforced on hacker mutation routes.
Tasks
-
Move handlers to
settings.go—getApplicationsEnabledandsetApplicationsEnabledare settings operations, not application CRUD. Move them tocmd/api/settings.gofor consistency with other setting toggles (getReviewAssignmentToggle,getAdminScheduleEditToggle,getHackathonDateRange). -
Create
ApplicationsEnabledMiddlewareincmd/api/middlewares.go— Following theAdminScheduleEditPermissionMiddlewarepattern:- Call
app.store.Application.GetApplicationsEnabled(ctx) - If disabled, return
403 Forbidden— "applications are currently closed" - If enabled, call
next.ServeHTTP(w, r)
- Call
-
Apply middleware to hacker mutation routes in
cmd/api/api.go:r.Route("/applications", func(r chi.Router) { r.Get("/me", app.getOrCreateApplicationHandler) r.Get("/enabled", app.getApplicationsEnabled) r.Group(func(r chi.Router) { r.Use(app.ApplicationsEnabledMiddleware) r.Patch("/me", app.updateApplicationHandler) r.Post("/me/submit", app.submitApplicationHandler) r.Post("/me/resume-upload-url", app.generateResumeUploadURLHandler) r.Delete("/me/resume", app.deleteResumeHandler) }) })
-
Add tests for the middleware (see
cmd/api/schedule_test.gofor reference) -
Update Swagger docs if any response codes change
Blocked by
This issue should only be started after PR #47 is merged with any requested fixes.
Labels
enhancement, refactor