diff --git a/demo/nextjs/app/dashboard/organization-card.tsx b/demo/nextjs/app/dashboard/organization-card.tsx index 70ad770189..8f69568fa8 100644 --- a/demo/nextjs/app/dashboard/organization-card.tsx +++ b/demo/nextjs/app/dashboard/organization-card.tsx @@ -74,7 +74,7 @@ export function OrganizationCard(props: { session: Session | null }) { ); return ( - + Organization
diff --git a/demo/nextjs/app/dashboard/page.tsx b/demo/nextjs/app/dashboard/page.tsx index 868a1e3427..6ab96af7c5 100644 --- a/demo/nextjs/app/dashboard/page.tsx +++ b/demo/nextjs/app/dashboard/page.tsx @@ -1,27 +1,29 @@ -import { auth } from "@/lib/auth" -import { headers } from "next/headers" -import { redirect } from "next/navigation" -import UserCard from "./user-card" -import { OrganizationCard } from "./organization-card" - +import { auth } from "@/lib/auth"; +import { headers } from "next/headers"; +import { redirect } from "next/navigation"; +import UserCard from "./user-card"; +import { OrganizationCard } from "./organization-card"; export default async function DashboardPage() { - const [session, activeSessions] = await Promise.all([ - auth.api.getSession({ - headers: headers() - }), - auth.api.listSessions({ - headers: headers() - }) - ]).catch(e => { - throw redirect("/sign-in") - }) - return ( -
-
- - -
-
- ) -} \ No newline at end of file + const [session, activeSessions] = await Promise.all([ + auth.api.getSession({ + headers: headers(), + }), + auth.api.listSessions({ + headers: headers(), + }), + ]).catch((e) => { + throw redirect("/sign-in"); + }); + return ( +
+
+ + +
+
+ ); +} diff --git a/demo/nextjs/app/dashboard/user-card.tsx b/demo/nextjs/app/dashboard/user-card.tsx index 0b993e4b2b..413e371f57 100644 --- a/demo/nextjs/app/dashboard/user-card.tsx +++ b/demo/nextjs/app/dashboard/user-card.tsx @@ -89,7 +89,7 @@ export default function UserCard(props: { const [isSignOut, setIsSignOut] = useState(false); return ( - + User @@ -407,6 +407,7 @@ function ChangePassword() { toast.error("Passwords do not match"); return; } + a; if (newPassword.length < 8) { toast.error("Password must be at least 8 characters"); return; diff --git a/demo/nextjs/lib/auth-client.ts b/demo/nextjs/lib/auth-client.ts index dd3973580c..5a87c355f2 100644 --- a/demo/nextjs/lib/auth-client.ts +++ b/demo/nextjs/lib/auth-client.ts @@ -4,6 +4,7 @@ import { passkeyClient, twoFactorClient, } from "better-auth/client/plugins"; +import { toast } from "sonner"; export const client = createAuthClient({ plugins: [ @@ -14,7 +15,11 @@ export const client = createAuthClient({ passkeyClient(), ], fetchOptions: { - credentials: "include", + onError(e) { + if (e.error.status === 429) { + toast.error("Too many requests. Please try again later."); + } + }, }, }); diff --git a/demo/nextjs/lib/auth.ts b/demo/nextjs/lib/auth.ts index 646312d69e..f43a39b0f4 100644 --- a/demo/nextjs/lib/auth.ts +++ b/demo/nextjs/lib/auth.ts @@ -41,6 +41,8 @@ export const auth = betterAuth({ plugins: [ rateLimiter({ enabled: true, + + max: 1000, }), organization({ async sendInvitationEmail(data) { diff --git a/packages/better-auth/src/api/routes/session.ts b/packages/better-auth/src/api/routes/session.ts index ebed09228b..c2f543eb33 100644 --- a/packages/better-auth/src/api/routes/session.ts +++ b/packages/better-auth/src/api/routes/session.ts @@ -51,7 +51,6 @@ export const getSession =