refactor: migrate session usage to better-auth API

This commit is contained in:
2026-04-06 22:41:57 -04:00
parent d7d52ef1a8
commit 15be2399c6
3 changed files with 14 additions and 14 deletions

View File

@@ -1,8 +1,11 @@
import { NextResponse } from "next/server";
import { auth } from "@/auth";
import { headers } from "next/headers";
export async function POST(request: Request) {
const session = await auth();
const session = await auth.api.getSession({
headers: await headers(),
});
if (!session?.user) {
return NextResponse.json(

View File

@@ -2,7 +2,7 @@
import { useEffect, useState } from 'react'
import { nanoid } from 'nanoid'
import { useSession } from 'next-auth/react'
import { useSession } from '@/lib/auth-client'
import { toast } from 'sonner'
import { saveEvent as addEvent, deleteEvent, getEvents as getAllEvents, clearEvents, updateEvent } from '@/lib/events-db'
@@ -44,7 +44,7 @@ export default function HomePage() {
})()
}, [])
const { data: session, status } = useSession()
const { data: session, isPending } = useSession()
const resetForm = () => {
setTitle('')
@@ -256,8 +256,8 @@ export default function HomePage() {
onImport={handleImport}
>
<AIToolbar
session={session}
status={status}
isAuthenticated={!!session?.user}
isPending={isPending}
aiPrompt={aiPrompt}
setAiPrompt={setAiPrompt}
aiLoading={aiLoading}