Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/app/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ async def event_generator():
data=event.model_dump_json(),
)

return EventSourceResponse(event_generator())
return EventSourceResponse(event_generator(), ping=15)


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1721,7 +1721,7 @@ async def event_generator():
data=evt.model_dump_json() if hasattr(evt, "model_dump_json") else _json.dumps(evt),
)

return EventSourceResponse(event_generator())
return EventSourceResponse(event_generator(), ping=15)


@router.get("/projects/{project_id}/search", response_model=ProjectSearchResponse)
Expand Down
13 changes: 9 additions & 4 deletions web/src/app/api/auth/[...all]/__tests__/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ function makePost(pathname: string) {
}

describe('POST /api/auth/[...all] — registration guard', () => {
const originalEnv = process.env;
const WATCHED = ['ALLOW_REGISTRATION'] as const;
const saved: Partial<Record<string, string>> = {};

beforeEach(() => {
process.env = { ...originalEnv };
for (const key of WATCHED) saved[key] = process.env[key];
});

afterAll(() => {
process.env = originalEnv;
afterEach(() => {
for (const key of WATCHED) {
if (saved[key] === undefined) delete process.env[key];
else process.env[key] = saved[key];
}
});

it('blocks /sign-up/email with 403 when ALLOW_REGISTRATION=false', async () => {
Expand All @@ -32,6 +36,7 @@ describe('POST /api/auth/[...all] — registration guard', () => {

expect(res.status).toBe(403);
const body = await res.json();
expect(body.error).toBe('Registration is disabled');
expect(body.message).toBe('Registration is disabled');
});

Expand Down
2 changes: 1 addition & 1 deletion web/src/app/api/auth/[...all]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const GET = handlers.GET;
export async function POST(request: NextRequest, _context: { params: Promise<{ all: string[] }> }) {
const url = new URL(request.url);
if (process.env.ALLOW_REGISTRATION === 'false' && url.pathname === '/api/auth/sign-up/email') {
return NextResponse.json({ message: 'Registration is disabled' }, { status: 403 });
return NextResponse.json({ error: 'Registration is disabled', message: 'Registration is disabled' }, { status: 403 });
}
return handlers.POST(request);
Comment on lines +11 to +15
Comment on lines 10 to 15
}
18 changes: 14 additions & 4 deletions web/src/app/api/auth/config/__tests__/route.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { GET } from '../route';

describe('GET /api/auth/config', () => {
const originalEnv = process.env;
const WATCHED = [
'GITHUB_CLIENT_ID',
'GITHUB_CLIENT_SECRET',
'GOOGLE_CLIENT_ID',
'GOOGLE_CLIENT_SECRET',
'ALLOW_REGISTRATION',
] as const;
const saved: Partial<Record<string, string>> = {};

beforeEach(() => {
process.env = { ...originalEnv };
for (const key of WATCHED) saved[key] = process.env[key];
});

afterAll(() => {
process.env = originalEnv;
afterEach(() => {
for (const key of WATCHED) {
if (saved[key] === undefined) delete process.env[key];
else process.env[key] = saved[key];
}
});

it('returns github=true when both GitHub secrets are set', async () => {
Expand Down
Loading