fix: OIDC auth flow, Vite proxy, and PostgreSQL query compat

- Add auth redirect in root layout for unauthenticated users
- Proxy OIDC routes (/login, /callback, /logout) through Vite dev server
- Strip Secure flag from OIDC cookies in dev mode (HTTP localhost)
- Disable retry on auth query to prevent stale cookie loops
- Fix SQLite .get()/.all()/.run() calls in category and global-item
  services for PostgreSQL compatibility
- Add userId scoping to category service functions
- Add OIDC error logging in auth middleware
- Apply linter auto-formatting across affected files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 18:25:31 +02:00
parent f7588827b1
commit 574a12e6fa
32 changed files with 315 additions and 253 deletions

View File

@@ -240,13 +240,7 @@ describe("Setup Service", () => {
await syncSetupItems(db, userId, setup.id, [item1.id, item2.id]);
// Change classifications
await updateItemClassification(
db,
userId,
setup.id,
item1.id,
"worn",
);
await updateItemClassification(db, userId, setup.id, item1.id, "worn");
await updateItemClassification(
db,
userId,
@@ -261,12 +255,8 @@ describe("Setup Service", () => {
const result = await getSetupWithItems(db, userId, setup.id);
expect(result?.items).toHaveLength(2);
const item2Result = result?.items.find(
(i: any) => i.name === "Jacket",
);
const item3Result = result?.items.find(
(i: any) => i.name === "Stove",
);
const item2Result = result?.items.find((i: any) => i.name === "Jacket");
const item3Result = result?.items.find((i: any) => i.name === "Stove");
expect(item2Result?.classification).toBe("consumable");
expect(item3Result?.classification).toBe("base");
});
@@ -293,13 +283,7 @@ describe("Setup Service", () => {
});
await syncSetupItems(db, userId, setup.id, [item.id]);
await updateItemClassification(
db,
userId,
setup.id,
item.id,
"worn",
);
await updateItemClassification(db, userId, setup.id, item.id, "worn");
const result = await getSetupWithItems(db, userId, setup.id);
expect(result?.items[0].classification).toBe("worn");
@@ -318,13 +302,7 @@ describe("Setup Service", () => {
expect(result?.items[0].classification).toBe("base");
// Update
await updateItemClassification(
db,
userId,
setup.id,
item.id,
"worn",
);
await updateItemClassification(db, userId, setup.id, item.id, "worn");
result = await getSetupWithItems(db, userId, setup.id);
expect(result?.items[0].classification).toBe("worn");
@@ -341,20 +319,8 @@ describe("Setup Service", () => {
await syncSetupItems(db, userId, setup1.id, [item.id]);
await syncSetupItems(db, userId, setup2.id, [item.id]);
await updateItemClassification(
db,
userId,
setup1.id,
item.id,
"worn",
);
await updateItemClassification(
db,
userId,
setup2.id,
item.id,
"base",
);
await updateItemClassification(db, userId, setup1.id, item.id, "worn");
await updateItemClassification(db, userId, setup2.id, item.id, "base");
const result1 = await getSetupWithItems(db, userId, setup1.id);
const result2 = await getSetupWithItems(db, userId, setup2.id);