Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Accounts 1: the bootstrap exits on its own, sign-out reloads the page

Claude495a0354bf65
diff --git a/src/components/security-settings.tsx b/src/components/security-settings.tsx
index 5b9a4677..d74a722d 100644
--- a/src/components/security-settings.tsx
+++ b/src/components/security-settings.tsx
@@ -2,7 +2,6 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { Copy, KeyRound, Loader2, LogOut, ShieldAlert, ShieldCheck, Trash2 } from "lucide-react";
-import { useRouter } from "next/navigation";
import { useId, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
@@ -196,7 +195,6 @@ function Tokens({ status, onChange }: { status: AuthStatus; onChange: () => void
export function SecuritySettings() {
const qc = useQueryClient();
- const router = useRouter();
const status = useQuery({ queryKey: ["auth"], queryFn: () => call<AuthStatus>("/api/auth/password", "GET") });
const refresh = () => void qc.invalidateQueries({ queryKey: ["auth"] });
if (!status.data) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;
@@ -213,7 +211,8 @@ export function SecuritySettings() {
className="-my-1 h-7"
onClick={async () => {
await fetch("/api/auth/logout", { method: "POST" });
- router.replace("/login");
+ // A full load (the proxy sends it to sign in): nothing from the signed-in session stays in memory.
+ window.location.reload();
}}
>
<LogOut /> Sign out
diff --git a/src/instrumentation.ts b/src/instrumentation.ts
index 9b3a36de..d2bf1533 100644
--- a/src/instrumentation.ts
+++ b/src/instrumentation.ts
@@ -9,15 +9,8 @@
*/
export async function register() {
if (process.env.NEXT_RUNTIME !== "nodejs" || process.env.NEXT_PHASE === "phase-production-build") return;
- const { bootstrapIdentity, StartupError } = await import("./server/identity/bootstrap");
- try {
- const report = await bootstrapIdentity();
- if (report.snapshot) console.log(`Fuobe saved a copy of the database before accounts: ${report.snapshot.db}`);
- if (report.importedPassword) console.log("Fuobe moved the password to accounts: sign in once more in each browser.");
- } catch (e) {
- console.error(e instanceof StartupError ? `Fuobe can't start: ${e.message}` : e);
- process.exit(1);
- }
+ const { startIdentity } = await import("./server/identity/bootstrap");
+ await startIdentity();
const { ensureRunner } = await import("./server/generations");
ensureRunner();
const { ensureTrashPurge } = await import("./server/library");
diff --git a/src/server/identity/bootstrap.ts b/src/server/identity/bootstrap.ts
index e09249e1..68afc966 100644
--- a/src/server/identity/bootstrap.ts
+++ b/src/server/identity/bootstrap.ts
@@ -133,3 +133,15 @@ export async function bootstrapIdentity(): Promise<BootstrapReport> {
report.signin = installValue(INSTALL.signin) === "on" ? "on" : "off";
return report;
}
+
+/** The bootstrap as the server runs it (instrumentation.ts): a few lines for the terminal, or one line and exit. */
+export async function startIdentity(): Promise<void> {
+ try {
+ const report = await bootstrapIdentity();
+ if (report.snapshot) console.log(`Fuobe saved a copy of the database before accounts: ${report.snapshot.db}`);
+ if (report.importedPassword) console.log("Fuobe moved the password to accounts: sign in once more in each browser.");
+ } catch (e) {
+ console.error(e instanceof StartupError ? `Fuobe can't start: ${e.message}` : e);
+ process.exit(1);
+ }
+}
diff --git a/src/server/identity/owner.ts b/src/server/identity/owner.ts
index 6ad8ba48..104bb915 100644
--- a/src/server/identity/owner.ts
+++ b/src/server/identity/owner.ts
@@ -1,5 +1,6 @@
import "server-only";
import { isAPIError } from "better-auth/api";
+import { REFUSAL_COPY } from "@/lib/sign-in-refusals";
import { db } from "../db";
import { bumpIdentityConfig, envOwnerPassword, INSTALL, setInstallValue } from "../mode";
import * as ops from "./admin-ops";
@@ -55,8 +56,9 @@ export async function signInOwner(password: string, headers: Headers): Promise<S
return { ok: true, setCookies: res.headers?.getSetCookie() ?? [] };
} catch (e) {
if (isAPIError(e)) {
+ // A refusal with its own copy (pending, turned off, dormant…); anything else reads as a wrong password.
const code = (e.body as { code?: string } | undefined)?.code;
- if (code && code !== "INVALID_EMAIL_OR_PASSWORD") return { ok: false, code, message: e.message };
+ if (code && code in REFUSAL_COPY) return { ok: false, code, message: e.message };
return { ok: false };
}
throw e;