mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 22:27:56 +01:00
Loki's OrangeCat provider kept Auth.js's default profile, which carries the email. For an OrangeCat identity Loki had not seen, that meant: the signIn callback looked the address up in users, PATCHED that account (image, name) and stamped its email as verified — on the strength of an address OrangeCat does not verify — and then the adapter refused the sign-in with OAuthAccountNotLinked. The provider is now accountkit's (v0.2.1): same client_secret_post, PKCE and capability scopes, and a profile with no email. An OrangeCat sign-in resolves its user through accountkit's withOrangecatIdentity wrapped around the Drizzle adapter, by sub alone (users.orangecatActorId, else the accounts row of an older link). keepTokens keeps writing the accounts row, which powers publish/promote/wallet. A new OrangeCat user keeps its address only when no Loki account holds it; else email stays null (never a made-up address). forgot-password keeps Loki's rule (a GitHub/Google account without a password may set one) but never mails an account only OrangeCat created (lib/auth/reset-eligibility.ts + test). pages.error: Auth.js's bare "Error" page is replaced by /sign-in/error, accountkit's SignInError; Try again goes back to /sign-in, which starts whichever method the person picks. Added to the responsive audit. Password, PIN, X and demo accounts are untouched. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
// Pins who "forgot password" may email. An account only OrangeCat created
|
|
// must get no reset link (its address is unverified); Loki's own rule — a
|
|
// GitHub/Google account without a password may set one — must survive.
|
|
import assert from "node:assert/strict";
|
|
import { lokiMayReceivePasswordReset as may } from "../../src/lib/auth/reset-eligibility";
|
|
|
|
const ACTOR = "0a4a0e2e-1111-4222-8333-444455556666";
|
|
const base = { email: "a@x.ch", passwordHash: null, orangecatActorId: null };
|
|
|
|
assert.equal(may({ ...base, orangecatActorId: ACTOR }, ["orangecat"]), false, "OrangeCat-only");
|
|
assert.equal(may(base, ["orangecat"]), false, "OrangeCat-only, linked before the actor column");
|
|
assert.equal(may(base, ["github"]), true, "GitHub account may set a password (Loki's rule)");
|
|
assert.equal(
|
|
may({ ...base, orangecatActorId: ACTOR }, ["orangecat", "google"]),
|
|
true,
|
|
"also Google",
|
|
);
|
|
assert.equal(
|
|
may({ ...base, passwordHash: "h", orangecatActorId: ACTOR }, ["orangecat"]),
|
|
true,
|
|
"own password",
|
|
);
|
|
assert.equal(may({ ...base, email: null }, []), false, "no address");
|
|
|
|
console.log("reset-eligibility: ok");
|