diff --git a/docs/components/landing/hero.tsx b/docs/components/landing/hero.tsx index 4d660e39d0..1455b49390 100644 --- a/docs/components/landing/hero.tsx +++ b/docs/components/landing/hero.tsx @@ -5,7 +5,7 @@ import useMeasure from "react-use-measure"; import Link from "next/link"; import clsx from "clsx"; import { Button } from "@/components/ui/button"; -import { Check, Copy, CornerRightUp } from "lucide-react"; +import { Check, Copy } from "lucide-react"; import { useTheme } from "next-themes"; import { Highlight, themes } from "prism-react-renderer"; import { AnimatePresence, motion, MotionConfig } from "framer-motion"; diff --git a/packages/better-auth/src/plugins/haveibeenpwned/haveibeenpwned.test.ts b/packages/better-auth/src/plugins/haveibeenpwned/haveibeenpwned.test.ts index 6e85a288c4..754d32ce06 100644 --- a/packages/better-auth/src/plugins/haveibeenpwned/haveibeenpwned.test.ts +++ b/packages/better-auth/src/plugins/haveibeenpwned/haveibeenpwned.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; import { getTestInstance } from "../../test-utils/test-instance"; import { haveIBeenPwned } from "./index"; - describe("have-i-been-pwned", async () => { const { client } = await getTestInstance( { @@ -23,6 +22,9 @@ describe("have-i-been-pwned", async () => { }); expect(result.error).not.toBeNull(); expect(result.error?.status).toBe(400); + expect(result.error?.code).toBe( + "THE_PASSWORD_YOU_ENTERED_HAS_BEEN_COMPROMISED_PLEASE_CHOOSE_A_DIFFERENT_PASSWORD", + ); }); it("should allow account creation with strong, uncompromised password", async () => { @@ -46,7 +48,6 @@ describe("have-i-been-pwned", async () => { password: initialPassword, name: "Test User", }); - console.log(res); const result = await client.changePassword( { currentPassword: initialPassword, @@ -58,7 +59,6 @@ describe("have-i-been-pwned", async () => { }, }, ); - console.log({ result }); expect(result.error).toBeDefined(); expect(result.error?.status).toBe(400); }); diff --git a/packages/better-auth/src/plugins/haveibeenpwned/index.ts b/packages/better-auth/src/plugins/haveibeenpwned/index.ts index aeab5a2159..570ba47666 100644 --- a/packages/better-auth/src/plugins/haveibeenpwned/index.ts +++ b/packages/better-auth/src/plugins/haveibeenpwned/index.ts @@ -3,6 +3,11 @@ import { createHash } from "@better-auth/utils/hash"; import { betterFetch } from "@better-fetch/fetch"; import type { BetterAuthPlugin } from "../../types"; +const ERROR_CODES = { + PASSWORD_COMPROMISED: + "THE_PASSWORD_YOU_ENTERED_HAS_BEEN_COMPROMISED_PLEASE_CHOOSE_A_DIFFERENT_PASSWORD", +} as const; + async function checkPasswordCompromise( password: string, customMessage?: string, @@ -30,7 +35,6 @@ async function checkPasswordCompromise( message: `Failed to check password. Status: ${error.status}`, }); } - const lines = data.split("\n"); const found = lines.some( (line) => line.split(":")[0].toUpperCase() === suffix.toUpperCase(), @@ -41,6 +45,7 @@ async function checkPasswordCompromise( message: customMessage || "The password you entered has been compromised. Please choose a different password.", + code: ERROR_CODES.PASSWORD_COMPROMISED, }); } } catch (error) { @@ -74,4 +79,5 @@ export const haveIBeenPwned = (options?: HaveIBeenPwnedOptions) => }, }; }, + $ERROR_CODES: ERROR_CODES, }) satisfies BetterAuthPlugin;