feat(auth): add demo mode support using PUBLIC_DEMO_MODE

This commit is contained in:
yiling
2026-06-19 00:17:14 +08:00
parent ec6736b452
commit f1d52ac44e
4 changed files with 25 additions and 8 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ describe('authMiddleware', () => {
beforeEach(() => {
vi.resetAllMocks()
delete process.env.REVIEWER_READ_ONLY
delete process.env.PUBLIC_DEMO_MODE
})
it('allows access when authenticated', async () => {
@@ -54,7 +54,7 @@ describe('authMiddleware', () => {
describe('read-only mode', () => {
beforeEach(() => {
process.env.REVIEWER_READ_ONLY = '1'
process.env.PUBLIC_DEMO_MODE = '1'
})
it('allows GET for reviewer', async () => {
+1 -1
View File
@@ -29,7 +29,7 @@ export const authMiddleware = createMiddleware<{
c.set('user', user)
if (process.env.REVIEWER_READ_ONLY === '1') {
if (process.env.PUBLIC_DEMO_MODE === '1') {
const method = c.req.method.toUpperCase()
const path = c.req.path
if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(method) && !path.endsWith('/search')) {