diff --git a/servers/fastapi/api/v1/auth/router.py b/servers/fastapi/api/v1/auth/router.py index 17b75dba..8f973d9c 100644 --- a/servers/fastapi/api/v1/auth/router.py +++ b/servers/fastapi/api/v1/auth/router.py @@ -49,16 +49,14 @@ async def setup_credentials(body: AuthCredentialsRequest, request: Request): except ValueError as exc: raise HTTPException(status_code=400, detail=str(exc)) from exc - token = create_session_token(body.username.strip()) - response = JSONResponse( + username = body.username.strip() + return JSONResponse( { "configured": True, - "authenticated": True, - "username": body.username.strip(), + "authenticated": False, + "username": username, } ) - set_session_cookie(response, token, request) - return response @API_V1_AUTH_ROUTER.post("/login") diff --git a/servers/nextjs/components/Auth/AuthGate.tsx b/servers/nextjs/components/Auth/AuthGate.tsx index 88b880d2..be88741e 100644 --- a/servers/nextjs/components/Auth/AuthGate.tsx +++ b/servers/nextjs/components/Auth/AuthGate.tsx @@ -126,10 +126,25 @@ export default function AuthGate() { return; } + if (isSetupMode) { + setStatus({ + configured: true, + authenticated: false, + username: (payload as AuthStatus).username ?? cleanedUsername, + }); + setPassword(""); + setConfirmPassword(""); + toast.success("Account created", { + description: "Sign in with your new username and password to continue.", + duration: 6000, + }); + return; + } + setStatus({ - configured: Boolean(payload.configured), - authenticated: Boolean(payload.authenticated), - username: payload.username ?? cleanedUsername, + configured: Boolean((payload as AuthStatus).configured), + authenticated: Boolean((payload as AuthStatus).authenticated), + username: (payload as AuthStatus).username ?? cleanedUsername, }); setPassword(""); setConfirmPassword(""); @@ -289,7 +304,7 @@ export default function AuthGate() { ? "Saving credentials…" : "Signing in…" : isSetupMode - ? "Create login and continue" + ? "Create account" : "Sign in"}