Make Cobble a local install: setup flow, bots-first admin, settings
Local, password-only auth: - No public pages; everything outside /admin and /auth redirects in - First run (no users) sends every page to /auth/signup, which creates the super admin (user #1) once and then locks - Login is email/username + password; removed the emailed-code flow, /auth/sso and email password reset - Google login kept for existing accounts only, never creates them - seed-super-admin now requires SEED_SUPER_ADMIN_PASSWORD Bots-first admin: - /admin and closed sections (people, logs, backups) redirect to /admin/bots; only bots and settings are live (AdminSections) - Removed the old admin layout; every /admin page uses the bots rail - Coordinator bot created at signup/seed and by /admin/bots (ensureCoordinatorBot), which redirects to its chat - bots.system_prompt (markdown) with a default coordinator prompt - seed-bots reuses the existing coordinator Settings: - Sub pages general (default), profile, change-password, listed in the rail with a back link; unknown settings paths redirect to general - Redesigned settings UI: pane header, grouped rows, sticky save bar - General: System/Light/Dark theme, saved per device Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,31 +1,25 @@
|
||||
import fetchApi from "@moduletrace/twui/utils/fetch/fetchApi";
|
||||
import { AdminHomePath } from "@/src/dict/admin-sections-dict";
|
||||
import type useFormInit from "@/src/hooks/use-form-init";
|
||||
import type { ApiReqParams, LoginMethod, SignupFormObject } from "@/src/types";
|
||||
import type { ApiReqParams, SignupFormObject } from "@/src/types";
|
||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
||||
import saveSSOPendingLogin from "@/src/functions/frontend/save-sso-pending-login";
|
||||
import validatePassword from "@/src/utils/validate-password";
|
||||
|
||||
type Params = ReturnType<typeof useFormInit<SignupFormObject>> & {
|
||||
method: LoginMethod;
|
||||
};
|
||||
type Params = ReturnType<typeof useFormInit<SignupFormObject>>;
|
||||
|
||||
export default async function submitSignupForm({
|
||||
setLoading,
|
||||
setStatus,
|
||||
form,
|
||||
method,
|
||||
}: Params) {
|
||||
const password_error =
|
||||
method == "password"
|
||||
? validatePassword({ password: form.password })
|
||||
: undefined;
|
||||
const password_error = validatePassword({ password: form.password });
|
||||
|
||||
if (password_error) {
|
||||
setStatus({ error: true, msg: password_error });
|
||||
return;
|
||||
}
|
||||
|
||||
if (method == "password" && form.password != form.confirm_password) {
|
||||
if (form.password != form.confirm_password) {
|
||||
setStatus({ error: true, msg: "The passwords don't match." });
|
||||
return;
|
||||
}
|
||||
@@ -42,18 +36,14 @@ export default async function submitSignupForm({
|
||||
last_name: form.last_name,
|
||||
username: form.username,
|
||||
email: form.email,
|
||||
password: method == "password" ? form.password : undefined,
|
||||
password: form.password,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (res.success) {
|
||||
saveSSOPendingLogin({
|
||||
identifier: form.email?.trim() || "",
|
||||
method,
|
||||
});
|
||||
window.location.pathname = `/auth/sso`;
|
||||
window.location.pathname = AdminHomePath;
|
||||
} else {
|
||||
setStatus({
|
||||
error: true,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Form from "@moduletrace/twui/form/Form";
|
||||
import LoadingOverlay from "@moduletrace/twui/elements/LoadingOverlay";
|
||||
import useFormInit from "@/src/hooks/use-form-init";
|
||||
import useLoginMethod from "@/src/hooks/use-login-method";
|
||||
import { type SignupFormObject } from "@/src/types";
|
||||
import LoginShell from "@/src/components/general/login-shell";
|
||||
import SignupFormName from "./signup-form-name";
|
||||
@@ -9,34 +8,27 @@ import SignupFormUsername from "./signup-form-username";
|
||||
import SignupFormEmail from "./signup-form-email";
|
||||
import SignupFormPassword from "./signup-form-password";
|
||||
import SignupFormConfirmPassword from "./signup-form-confirm-password";
|
||||
import GoogleAuthSection from "@/src/components/general/google-auth-section";
|
||||
import SignupFormAction from "./signup-form-action";
|
||||
import submitSignupForm from "../../(functions)/submit-signup-form";
|
||||
|
||||
export default function SignupForm() {
|
||||
const init = useFormInit<SignupFormObject>();
|
||||
const { loading, status } = init;
|
||||
const method = useLoginMethod();
|
||||
|
||||
return (
|
||||
<LoginShell status={status}>
|
||||
<GoogleAuthSection {...init} mode="signup" />
|
||||
<Form
|
||||
className="w-full flex items-center justify-center relative gap-4"
|
||||
onSubmit={() => {
|
||||
submitSignupForm({ ...init, method });
|
||||
submitSignupForm(init);
|
||||
}}
|
||||
>
|
||||
{loading && <LoadingOverlay />}
|
||||
<SignupFormEmail {...init} />
|
||||
<SignupFormName {...init} />
|
||||
<SignupFormUsername {...init} />
|
||||
{method == "password" ? (
|
||||
<>
|
||||
<SignupFormPassword {...init} />
|
||||
<SignupFormConfirmPassword {...init} />
|
||||
</>
|
||||
) : null}
|
||||
<SignupFormPassword {...init} />
|
||||
<SignupFormConfirmPassword {...init} />
|
||||
<SignupFormAction {...init} />
|
||||
</Form>
|
||||
</LoginShell>
|
||||
|
||||
@@ -6,8 +6,8 @@ export default function SignupFormAction({}: ReturnType<
|
||||
typeof useFormInit<SignupFormObject>
|
||||
>) {
|
||||
return (
|
||||
<Button title="Create account" type="submit" className="w-full">
|
||||
Create account
|
||||
<Button title="Create super admin" type="submit" className="w-full">
|
||||
Create super admin
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -2,33 +2,23 @@ import Section from "@moduletrace/twui/layout/Section";
|
||||
import Container from "@moduletrace/twui/layout/Container";
|
||||
import Stack from "@moduletrace/twui/layout/Stack";
|
||||
import AuthHero from "@/src/components/general/auth-hero";
|
||||
import AuthFooterLink from "@/src/components/general/auth-footer-link";
|
||||
import { SiteData } from "@/src/data/site-data";
|
||||
import SignupForm from "../(partials)/signup-form";
|
||||
import useLoginMethod from "@/src/hooks/use-login-method";
|
||||
|
||||
/**
|
||||
* First-run setup. Only reachable while no account exists.
|
||||
*/
|
||||
export default function SignupFormSection() {
|
||||
const method = useLoginMethod();
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Container>
|
||||
<Stack className="w-full items-center max-w-md mx-auto gap-8">
|
||||
<AuthHero
|
||||
eyebrow="Get started"
|
||||
title="Create your account"
|
||||
description={
|
||||
method == "password"
|
||||
? `Sign up for ${SiteData["SiteName"]}. We'll email you a code to confirm it's you.`
|
||||
: `Sign up for ${SiteData["SiteName"]} and we'll email you a one-time login code.`
|
||||
}
|
||||
eyebrow="Set up"
|
||||
title="Create the super admin"
|
||||
description={`This is the first account on this ${SiteData["SiteName"]} install. It can add everyone else.`}
|
||||
/>
|
||||
<SignupForm />
|
||||
<AuthFooterLink
|
||||
prompt="Already have an account?"
|
||||
title="Log in"
|
||||
url="/auth/login"
|
||||
/>
|
||||
</Stack>
|
||||
</Container>
|
||||
</Section>
|
||||
|
||||
@@ -7,6 +7,6 @@ export default function SignupPage() {
|
||||
}
|
||||
|
||||
export const meta: BunextPageModuleMeta = {
|
||||
title: `Sign Up | ${SiteData["SiteName"]}`,
|
||||
description: `Create your ${SiteData["SiteName"]} account.`,
|
||||
title: `Set Up | ${SiteData["SiteName"]}`,
|
||||
description: `Create the super admin for this ${SiteData["SiteName"]} install.`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user