v0.71.0: admin panel — users table, login/sessions, generic DB CRUD modal
CI / build + unit + e2e (pull_request) Failing after 13m35s
CI / build + unit + e2e (pull_request) Failing after 13m35s
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { getGameDb } from '@/lib/db/client';
|
||||
import { createSession } from '@/lib/auth';
|
||||
|
||||
// TEST-ONLY hook (v0.71.0) — mints a live session for the SEEDED admin user server-side and
|
||||
// returns its id, so the e2e suite can exercise the authenticated Admin panel WITHOUT the real
|
||||
// admin password ever appearing in test code (the spec forbids it). No body. Disabled unless
|
||||
// FLIGHT_TEST_HOOKS=1 (set in docker-compose.ci.yml for the CI stack only); every other
|
||||
// deployment 404s here, like its /api/test/* siblings.
|
||||
|
||||
export async function POST() {
|
||||
if (process.env.FLIGHT_TEST_HOOKS !== '1') {
|
||||
return Response.json({ error: 'test hooks disabled' }, { status: 404 });
|
||||
}
|
||||
|
||||
const inst = await getGameDb();
|
||||
const res = inst.raw.exec("SELECT id FROM users WHERE username = 'kamilkrzywda'");
|
||||
const userId = res[0]?.values?.[0]?.[0];
|
||||
if (typeof userId !== 'string') {
|
||||
return Response.json({ error: 'seeded admin user missing' }, { status: 500 });
|
||||
}
|
||||
const sessionId = await createSession(inst, userId);
|
||||
return Response.json({ sessionId });
|
||||
}
|
||||
Reference in New Issue
Block a user