mirror of
https://github.com/bitbaum/petvity.git
synced 2026-12-04 05:17:25 +01:00
* feat(auth): every way in on AccountKit's own screens Petvity has answered sign-in from AccountKit since this morning, through the Auth.js compat layer, with AccountKit's sign-up, recovery, passkey and two-factor endpoints closed. This finishes the move: - /login, /register and /forgot-password render AccountKit's SignInForm, SignUpForm and recovery form: email and password, an email sign-in link, passkeys, two-factor, recovery, Continue with OrangeCat and the shared bitbaum sign-in, each shown when its env is set. /portal/settings/security renders AccountPanel (password, passkeys, second factor, linked sign-ins, deleting the account). - The compat layer passes screens: "accountkit" (AccountKit 0.20.0): every AccountKit endpoint is open, and useSession and signOut keep Petvity's session shape. - AccountKit is the only credential writer. Petvity's registration route, reset routes, settings password change and its own deletion are removed, and so are Auth.js, its edge config, the Drizzle adapter and the credential-less Google provider. - Migration 0009 (additive) makes the panel's rename and deletion reach users. The import attaches the new trigger too. - A Petvity plugin keeps the shared demo account explorable (no sign-in changes, no deletion, no mailed links) and keeps ADMIN_EMAILS promotion at a password or email-link sign-in. - Every imported account keeps working: same ids, bcrypt hashes through legacyBcrypt, OrangeCat links, roles on users. browser-smoke.yml now runs every way in against the production build and a migrated, imported PostgreSQL: the method set at 320px and 390px, sign up, sign out, a wrong password, sign in, an Auth.js-era bcrypt account, a reset through the mailed link and an email sign-in link. AccountKit's real mail is caught by scripts/ci/mail-sink.cjs. Long button labels now wrap (.btn-wrap): the shared sign-in's label overflowed a 320px screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 * fix(ci): the mail sink path needs no runner context Job-level env cannot read the runner context, so the workflow did not parse. The sink sits at a fixed path outside the uploaded artifacts. 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>
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
/**
|
|
* Petvity's accounts, on AccountKit's shared runtime: email and password, an
|
|
* email sign-in link, passkeys, two-factor codes, password recovery, Sign in
|
|
* with OrangeCat and the shared bitbaum sign-in, each shown when its env is set
|
|
* (signInMethods in lib/auth/methods.ts). AccountKit is the only writer of
|
|
* credentials (docs/ACCOUNTKIT-MIGRATION.md).
|
|
*/
|
|
import bcrypt from "bcryptjs";
|
|
import { createAuthRuntime } from "@bitbaum/accountkit/auth/next";
|
|
import { createAuthMailer } from "@bitbaum/accountkit/auth/mail";
|
|
import { APP_URL } from "@/lib/config/app";
|
|
import { getInstance } from "@/lib/db";
|
|
import { authTables } from "@/lib/db/accountkit";
|
|
import { ensurePetvityUser } from "./accounts";
|
|
import { petvityPlugin } from "./petvity-plugin";
|
|
|
|
/** The public origin every redirect and every AccountKit origin check uses. */
|
|
export function siteUrl(env: NodeJS.ProcessEnv = process.env): string {
|
|
return (env.AUTH_URL || APP_URL).replace(/\/$/, "");
|
|
}
|
|
|
|
const site = { url: siteUrl(), title: "Petvity", slug: "petvity" };
|
|
|
|
/** Account mail through the fleet transport (RESEND_*), as Petvity's own is. */
|
|
export const authMail = createAuthMailer({ site });
|
|
|
|
// The secret is BETTER_AUTH_SECRET, or the AUTH_SECRET the box already holds.
|
|
export const sharedAuth = createAuthRuntime({
|
|
site,
|
|
mail: authMail,
|
|
isDatabaseConfigured: (env) => Boolean(env.DATABASE_URL),
|
|
getDatabase: () => getInstance(),
|
|
schema: authTables,
|
|
// Hashes imported from Auth.js (and the demo account's, which the reset cron
|
|
// writes to users.password and the mirror copies) are bcrypt; every password
|
|
// set through AccountKit is its native scrypt.
|
|
legacyBcrypt: bcrypt,
|
|
// users.id is a uuid that every Petvity table references.
|
|
ids: "uuid",
|
|
onAccountCreated: ensurePetvityUser,
|
|
plugins: [petvityPlugin()],
|
|
});
|