import { CredentialsSignin } from "next-auth"; /** * Thrown from `authorize()` (in auth.ts) when a PENDING user's credentials * are otherwise correct. Kept distinct from a plain `return null` (bad * email/password) so `login()` (in lib/actions/auth.ts) can show a message * that actually explains why the login failed, instead of "incorrect email * or password." * * Auth.js rethrows errors from `authorize()` as-is when `signIn()` is * called from a Server Action (see @auth/core's raw-mode handling), so * `login()` can catch this by its `code` rather than parsing `message`. */ export class PendingAccountSignin extends CredentialsSignin { code = "pending-account"; } /** * Thrown from the "account-switch" provider's authorize() (in auth.ts) * when the one-time switch token is missing, already used, expired, or * the target account can't log in (e.g. PENDING). signIn() in the * toggleAccount action (lib/actions/account-links.ts) then fails with it * and the Profile page shows an error toast, keeping the user on the * login flow instead of silently switching accounts. * * (Same mechanism as PendingAccountSignin: Auth.js rethrows errors from * authorize() as-is when signIn() is called from a route/Server Action.) */ export class SwitchAccountSignin extends CredentialsSignin { code = "switch-account"; }