Skip to content

Refactor/56 addapplicationsenabledmiddleware#67

Open
5sansiva wants to merge 14 commits intomainfrom
refactor/56-addapplicationsenabledmiddleware
Open

Refactor/56 addapplicationsenabledmiddleware#67
5sansiva wants to merge 14 commits intomainfrom
refactor/56-addapplicationsenabledmiddleware

Conversation

@5sansiva
Copy link
Copy Markdown
Collaborator

Summary
Refactor: Move ApplicationsEnabled to Settings and wire up middleware

Store Layer
Moved GetApplicationsEnabled / SetApplicationsEnabled from the Application interface → Settings interface in storage.go (these are global toggles, not application CRUD)
Moved implementations from ApplicationsStore (applications.go) → SettingsStore (settings.go)
Moved mock stubs from MockApplicationStore → MockSettingsStore in mock_store.go

API Layer
Wired ApplicationsEnabledMiddleware onto hacker mutation routes (PATCH /me, POST /me/submit, POST /me/resume-upload-url, DELETE /me/resume)
Added unguarded GET /applications/enabled route so the frontend can check if submissions are open
Super admins bypass the middleware check; all other users receive 403 when applications are disabled
Updated getApplicationsEnabled / setApplicationsEnabled handlers to call app.store.Settings.* instead of app.store.Application.*

Tests
Added TestApplicationsEnabledMiddleware covering:
Returns 403 when applications are disabled
Passes through with 200 when applications are enabled
Uses .Once() on mock expectations to prevent cross-test pollution

Misc
Fixed Swagger tags: admin → admin/applications, superadmin → superadmin/applications

@5sansiva 5sansiva requested review from anishalle and balebbae March 26, 2026 18:46
Copy link
Copy Markdown
Collaborator

@anishalle anishalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants