fix onboarding cache and remove the stupid renovate stuff

This commit is contained in:
KingKDot
2026-07-15 10:14:42 -05:00
parent 0277c2dbcf
commit c577d8b2b6
5 changed files with 34 additions and 63 deletions
+4 -1
View File
@@ -159,7 +159,10 @@ if (host) {
async function loadCurrentUser() {
try {
const res = await fetch("/api/auth/me", { credentials: "include" });
const res = await fetch("/api/auth/me", {
credentials: "include",
cache: "no-store",
});
if (!res.ok) {
return;
}
@@ -119,6 +119,7 @@ export function showOnboardingIfNeeded(user) {
const response = await fetch("/api/auth/onboarding/complete", {
method: "POST",
credentials: "include",
cache: "no-store",
});
if (!response.ok) throw new Error("Could not save your onboarding status.");
overlay.remove();
+10
View File
@@ -61,6 +61,7 @@ describe("account onboarding", () => {
const meUrl = new URL("https://localhost/api/auth/me");
const before = await handleAuthRoutes(new Request(meUrl, { headers }), meUrl, mockServer);
expect(before?.status).toBe(200);
expect(before?.headers.get("cache-control")).toContain("no-store");
expect((await before!.json()).needsOnboarding).toBe(true);
const completeUrl = new URL("https://localhost/api/auth/onboarding/complete");
@@ -70,10 +71,19 @@ describe("account onboarding", () => {
mockServer,
);
expect(completed?.status).toBe(200);
expect(completed?.headers.get("cache-control")).toContain("no-store");
const after = await handleAuthRoutes(new Request(meUrl, { headers }), meUrl, mockServer);
expect(after?.status).toBe(200);
expect((await after!.json()).needsOnboarding).toBe(false);
const repeated = await handleAuthRoutes(
new Request(completeUrl, { method: "POST", headers }),
completeUrl,
mockServer,
);
expect(repeated?.status).toBe(200);
expect((await repeated!.json()).needsOnboarding).toBe(false);
} finally {
deleteUser(created.userId!);
}
@@ -514,7 +514,10 @@ export async function handleAuthRoutes(
permissions,
}),
{
headers: { "Content-Type": "application/json" },
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-store, private",
},
},
);
}
@@ -526,7 +529,21 @@ export async function handleAuthRoutes(
}
completeUserOnboarding(user.userId);
return Response.json({ ok: true, needsOnboarding: false });
const dbUser = getUserById(user.userId);
if (!dbUser || dbUser.onboarding_completed_at === null) {
return Response.json(
{ error: "Could not save onboarding status" },
{
status: 500,
headers: { "Cache-Control": "no-store, private" },
},
);
}
return Response.json(
{ ok: true, needsOnboarding: false },
{ headers: { "Cache-Control": "no-store, private" } },
);
}
return null;