From e61501705efa3abdb6f6e3312b2bc38dc886391e Mon Sep 17 00:00:00 2001 From: Bereket Engida Date: Wed, 4 Sep 2024 12:54:02 +0300 Subject: [PATCH] examples --- docs/components/sidebar-content.tsx | 13 + docs/content/docs/basic-usage.mdx | 16 +- docs/content/docs/installation.mdx | 6 +- docs/content/docs/integrations/svelte-kit.mdx | 2 +- docs/package.json | 2 +- .../next-js/src/app/(auth)/sign-in/page.tsx | 41 ++- .../src/app/(auth)/two-factor/otp/page.tsx | 32 ++- .../next-js/src/components/add-passkey.tsx | 19 +- examples/next-js/src/lib/auth.ts | 6 +- .../src/adapters/internal-adapter.ts | 64 ++--- packages/better-auth/src/api/call.ts | 2 +- .../better-auth/src/api/middlewares/csrf.ts | 3 +- .../better-auth/src/api/routes/callback.ts | 26 +- packages/better-auth/src/api/routes/csrf.ts | 1 + .../better-auth/src/api/routes/session.ts | 73 +++-- .../better-auth/src/api/routes/sign-in.ts | 34 +-- .../better-auth/src/api/routes/sign-out.ts | 5 +- .../better-auth/src/client/fetch-plugins.ts | 11 + packages/better-auth/src/client/proxy.ts | 14 +- packages/better-auth/src/init.ts | 8 + .../better-auth/src/plugins/passkey/index.ts | 8 +- .../src/plugins/two-factor/otp/index.ts | 18 +- .../plugins/two-factor/verify-middleware.ts | 12 +- .../src/social-providers/discord.ts | 26 +- .../src/social-providers/facebook.ts | 26 +- .../src/social-providers/google.ts | 47 ++-- .../src/social-providers/spotify.ts | 25 +- .../src/social-providers/twitch.ts | 25 +- .../src/social-providers/twitter.ts | 28 +- .../better-auth/src/social-providers/utils.ts | 27 ++ packages/better-auth/src/types/context.ts | 21 +- packages/better-auth/src/types/plugins.ts | 12 +- packages/better-auth/src/types/provider.ts | 23 ++ packages/better-auth/src/utils/cookies.ts | 53 +++- packages/better-auth/src/utils/logger.ts | 5 + packages/better-auth/src/utils/state.ts | 25 +- pnpm-lock.yaml | 249 +++++++++++------- 37 files changed, 675 insertions(+), 333 deletions(-) diff --git a/docs/components/sidebar-content.tsx b/docs/components/sidebar-content.tsx index 9351b964..722bda5b 100644 --- a/docs/components/sidebar-content.tsx +++ b/docs/components/sidebar-content.tsx @@ -468,4 +468,17 @@ export const contents: Content[] = [ }, ], }, + { + title: "Guides", + Icon: () => ( + + ), + list: [{ + title: "Setting up Login with Github", + href: "/docs/guides/github-login", + icon: () => ( + + ) + }] + } ]; diff --git a/docs/content/docs/basic-usage.mdx b/docs/content/docs/basic-usage.mdx index 8fdefb9d..d2449add 100644 --- a/docs/content/docs/basic-usage.mdx +++ b/docs/content/docs/basic-usage.mdx @@ -3,9 +3,9 @@ title: Basic Usage description: Usage --- -## Signin and Signup with Email +## Sign-in & Sign-up with Email & Password -To use signin and signup with email, you need to configure the email and password authenticator. You can do this by adding the following code to your `auth.ts` file: +To use email and password as authentication startgey, you need to enable `emailAndPassword` in the `auth` config. ```ts title="auth.ts" twoslash import { betterAuth } from "better-auth" @@ -200,7 +200,7 @@ the client providers a `useSession` hook or a `session` object that you can use ```svelte title="user.svelte"
- ### Create Server + ### Create A Better Auth Instance better auth requries a file called `auth.ts` or `auth.config.ts` to be present in the root directory or one of the following directories: - `lib/` - `utils/` @@ -160,6 +160,10 @@ description: Installation ### Create Client better auth client comes with a support for differnt frameworks including React, Vue, Svelte, and Solid. You can also use it with vanilla javascript. + + + Make sure you import the client from the correct path. + ```ts diff --git a/docs/content/docs/integrations/svelte-kit.mdx b/docs/content/docs/integrations/svelte-kit.mdx index d2d861ea..e2994ec1 100644 --- a/docs/content/docs/integrations/svelte-kit.mdx +++ b/docs/content/docs/integrations/svelte-kit.mdx @@ -123,7 +123,7 @@ Some of the actinos are reactive. The client use [nano-store](https://github.com
``` -### Example: Getting Session on a ServerComponent +### Example: Getting Session on a loader ```ts title="+page.ts" import { auth } from "$lib/auth"; diff --git a/docs/package.json b/docs/package.json index 806b68f7..eb8825a0 100644 --- a/docs/package.json +++ b/docs/package.json @@ -41,7 +41,7 @@ "@tsparticles/engine": "^3.5.0", "@tsparticles/react": "^3.0.0", "@tsparticles/slim": "^3.5.0", - "better-auth": "^0.0.4", + "better-auth": "workspace:0.0.8-beta.5", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "cmdk": "1.0.0", diff --git a/examples/next-js/src/app/(auth)/sign-in/page.tsx b/examples/next-js/src/app/(auth)/sign-in/page.tsx index d260f422..c59d1ef4 100644 --- a/examples/next-js/src/app/(auth)/sign-in/page.tsx +++ b/examples/next-js/src/app/(auth)/sign-in/page.tsx @@ -13,6 +13,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { PasswordInput } from "@/components/ui/password-input"; import { authClient } from "@/lib/auth-client"; +import { GitHubLogoIcon } from "@radix-ui/react-icons"; import { Key } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/navigation"; @@ -95,7 +96,7 @@ export default function Page() { +