feat: setup better-auth

This commit is contained in:
Henry
2025-05-02 23:40:34 +01:00
parent 5996ad19c3
commit 091fea6f38
23 changed files with 4696 additions and 30 deletions

View File

@@ -3,6 +3,8 @@ import { useForm } from "react-hook-form";
import { FaGoogle } from "react-icons/fa";
import { z } from "zod";
import { authClient } from "@kan/auth";
import Button from "~/components/Button";
import Input from "~/components/Input";
import { api } from "~/utils/api";
@@ -55,7 +57,12 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) {
<div className="space-y-6">
<div>
<Button
onClick={() => loginWithOAuth.mutate({ provider: "google" })}
onClick={() =>
authClient.signIn.social({
provider: "google",
callbackURL: "/boards",
})
}
iconLeft={<FaGoogle />}
fullWidth
size="lg"

View File

@@ -16,6 +16,8 @@ export const env = createEnv({
server: {
POSTGRES_URL: z.string().url(),
STRIPE_SECRET_KEY: z.string().optional(),
GOOGLE_CLIENT_ID: z.string(),
GOOGLE_CLIENT_SECRET: z.string(),
},
/**

View File

@@ -0,0 +1,6 @@
import { toNodeHandler } from "better-auth/node";
import { auth } from "@kan/auth";
export const config = { api: { bodyParser: false } };
export default toNodeHandler(auth.handler);