Make demo login gate backend-authoritative
This commit is contained in:
@@ -4,7 +4,7 @@ import { useAuthStore } from './stores/auth'
|
||||
import { useAwardsStore } from './stores/awards'
|
||||
import { routes } from './router/routes'
|
||||
|
||||
const DEMO_GATE_HARD_DISABLED = import.meta.env.VITE_DEMO_GATE_ENABLED === 'false'
|
||||
const DEMO_GATE_FALLBACK_ENABLED = import.meta.env.VITE_DEMO_GATE_ENABLED !== 'false'
|
||||
const contentAdminRoutes = new Set(['admin-content', 'admin-settings'])
|
||||
|
||||
const router = createRouter({
|
||||
@@ -35,7 +35,9 @@ router.beforeEach(async (to) => {
|
||||
const isAdminRoute = to.path.startsWith('/admin')
|
||||
const isMaintenancePreview = isMaintenanceRoute && to.query.preview === 'true'
|
||||
const siteStatus = await loadSiteStatus()
|
||||
const demoGateEnabled = !DEMO_GATE_HARD_DISABLED && siteStatus?.demoLoginEnabled !== false
|
||||
const demoGateEnabled = siteStatus
|
||||
? siteStatus.demoLoginEnabled
|
||||
: DEMO_GATE_FALLBACK_ENABLED
|
||||
|
||||
if (isMaintenancePreview && !authStore.isAdmin) {
|
||||
return { name: 'login', query: { redirect: to.fullPath } }
|
||||
|
||||
Reference in New Issue
Block a user