refactor: migrate session usage to better-auth API
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user