mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 12:38:28 +01:00
* feat(auth): every way in on AccountKit's own screens
Botsmann signed people in against OrangeCat's GoTrue (auth.users). It now
runs on AccountKit (@bitbaum/accountkit 0.23) with AccountKit's own forms:
/auth/signin offers email and password, an emailed sign-in link, a
passkey, recovery through the mailed link and the second factor;
/auth/signup is sign-up; /account carries the account panel ("Sign-in and
security" in the account menu). "Continue with OrangeCat" and the shared
sign-in show when their clients are set, the link and recovery when mail
is. The GoTrue routes (/api/auth/signin, signup, forgot-password,
resend-verification, profile) and pages (callback, forgot-password,
reset-password, verify-email) and the cookie-session client are gone.
AccountKit's tables live in a host accounts database (drizzle/, loki
accounts-db.conf); the data stays in the botsmann supabase schema, which
every route already read with the service-role client. verifyUser now reads
AccountKit's session; /api/user/profile moves onto it too. New accounts get
uuid ids, and migration 013 drops the person columns' keys to auth.users,
which a new person's id is not in. Nothing is deleted. The profile editor
writes AccountKit's name and image.
Existing people keep their rows: scripts/db/accountkit-people.sql lists
everyone who owns rows with their OrangeCat actor id, and
scripts/db/accountkit-import.sql gives each an account under the same id,
linked to OrangeCat by that actor id, never by address (loki
accountkit-supabase.yml rehearses it rolled back, then imports).
Pages were served with public, max-age=3600 to every browser, account pages
included: after sign-out the browser showed its cached /account. /account
and /auth/* are now private, no-store. The account menu's trigger has a name.
tests/__tests__/accounts runs the ways in and the import on the committed
migration; browser-smoke.yml's account job rehearses the import and runs
the browser journey against the production build with AccountKit's real
mail caught by a sink.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* fix(auth): send a signed-out visitor to sign in with the router
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): the shared sign-in's button is matched by how it starts
AccountKit 0.24 names only the providers Morulia publishes, so the label
changes with Morulia.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): expect the shared sign-in only once Morulia publishes a provider
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci: run the checks on the journey change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
120 lines
3.5 KiB
TypeScript
120 lines
3.5 KiB
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
import {
|
|
AccountPanel,
|
|
SignInForm,
|
|
SignUpForm,
|
|
type AuthClasses,
|
|
type AuthLabels,
|
|
} from '@bitbaum/accountkit/auth/react';
|
|
import type { SignInMethods } from '@bitbaum/accountkit/auth';
|
|
import { authClient } from '@/lib/accounts/client';
|
|
import { ROUTES } from '@/lib/routes';
|
|
|
|
/**
|
|
* The fleet's account screens (@bitbaum/accountkit/auth/react) in Botsmann's
|
|
* look. The logic and the words are the package's, the same in every product.
|
|
*/
|
|
const CLASSES: Partial<AuthClasses> = {
|
|
stack: 'flex flex-col gap-5',
|
|
field: 'flex flex-col gap-1',
|
|
label: 'text-sm font-medium text-gray-700',
|
|
hint: 'text-sm leading-relaxed text-gray-600',
|
|
input:
|
|
'w-full min-h-11 px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-action disabled:bg-gray-50 disabled:text-gray-500',
|
|
button:
|
|
'inline-flex min-h-11 w-full items-center justify-center rounded-lg bg-action px-4 py-3 font-medium text-white transition-colors hover:bg-action-hover disabled:opacity-50',
|
|
buttonQuiet:
|
|
'inline-flex min-h-11 w-full items-center justify-center rounded-lg border border-gray-300 px-4 py-3 text-sm font-medium text-gray-800 transition-colors hover:bg-gray-50 disabled:opacity-50',
|
|
notice:
|
|
'rounded-lg border border-gray-200 bg-gray-50 px-4 py-3 text-sm leading-relaxed text-gray-700',
|
|
error: 'rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700',
|
|
divider:
|
|
'flex items-center gap-3 text-xs text-gray-500 before:h-px before:flex-1 before:bg-gray-200 after:h-px after:flex-1 after:bg-gray-200',
|
|
section: 'flex flex-col gap-4 border-t border-gray-200 pt-8',
|
|
sectionTitle: 'text-lg font-semibold text-gray-900',
|
|
link: 'break-all text-action underline underline-offset-4',
|
|
check: 'flex min-h-11 items-center gap-3 text-sm text-gray-700',
|
|
};
|
|
|
|
const textLink = 'inline-flex min-h-11 items-center font-medium text-action hover:underline';
|
|
|
|
export function BotsmannSignIn(props: {
|
|
labels: AuthLabels;
|
|
methods: SignInMethods;
|
|
next: string;
|
|
initialError: boolean;
|
|
}) {
|
|
return (
|
|
<SignInForm
|
|
client={authClient}
|
|
classes={CLASSES}
|
|
labels={props.labels}
|
|
methods={props.methods}
|
|
next={props.next}
|
|
signInPath={ROUTES.AUTH.SIGNIN}
|
|
initialError={props.initialError}
|
|
signUpLink={
|
|
<Link
|
|
prefetch={false}
|
|
href={`${ROUTES.AUTH.SIGNUP}?next=${encodeURIComponent(props.next)}`}
|
|
className={textLink}
|
|
>
|
|
{props.labels.createAccount}
|
|
</Link>
|
|
}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function BotsmannSignUp(props: {
|
|
labels: AuthLabels;
|
|
methods: SignInMethods;
|
|
next: string;
|
|
}) {
|
|
return (
|
|
<SignUpForm
|
|
client={authClient}
|
|
classes={CLASSES}
|
|
labels={props.labels}
|
|
methods={props.methods}
|
|
next={props.next}
|
|
signUpPath={ROUTES.AUTH.SIGNUP}
|
|
signInPath={ROUTES.AUTH.SIGNIN}
|
|
signInLink={
|
|
<Link
|
|
prefetch={false}
|
|
href={`${ROUTES.AUTH.SIGNIN}?next=${encodeURIComponent(props.next)}`}
|
|
className={textLink}
|
|
>
|
|
{props.labels.signIn}
|
|
</Link>
|
|
}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function BotsmannAccount(props: {
|
|
labels: AuthLabels;
|
|
methods: SignInMethods;
|
|
user: {
|
|
name: string;
|
|
email: string | null;
|
|
emailVerified: boolean;
|
|
role: string;
|
|
twoFactorEnabled: boolean;
|
|
};
|
|
linked: string[];
|
|
}) {
|
|
return (
|
|
<AccountPanel
|
|
client={authClient}
|
|
classes={CLASSES}
|
|
accountPath={ROUTES.AUTH.ACCOUNT}
|
|
homePath={ROUTES.HOME}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|