Fix all NextAuth v4 imports across codebase
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
import { prisma } from './db'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { auth } from '@/auth'
|
||||
import { getServerSession } from 'next-auth'
|
||||
import { authOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
import {
|
||||
validateListTitle,
|
||||
validateItemTitle,
|
||||
@@ -49,7 +50,7 @@ async function retryOperation<T>(
|
||||
export async function getLists() {
|
||||
try {
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to view lists')
|
||||
}
|
||||
@@ -109,7 +110,7 @@ export async function getLists() {
|
||||
export async function createList(title: string, color: string = '#3B82F6') {
|
||||
try {
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to create lists')
|
||||
}
|
||||
@@ -157,7 +158,7 @@ export async function getListWithItems(listId: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to view lists')
|
||||
}
|
||||
@@ -228,7 +229,7 @@ export async function getItem(itemId: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to view items')
|
||||
}
|
||||
@@ -305,7 +306,7 @@ export async function createItem(
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to create items')
|
||||
}
|
||||
@@ -387,7 +388,7 @@ export async function toggleItem(itemId: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to update items')
|
||||
}
|
||||
@@ -465,7 +466,7 @@ export async function updateItem(
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to update items')
|
||||
}
|
||||
@@ -560,7 +561,7 @@ export async function deleteItem(itemId: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to delete items')
|
||||
}
|
||||
@@ -626,7 +627,7 @@ export async function deleteList(listId: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to delete lists')
|
||||
}
|
||||
@@ -677,7 +678,7 @@ export async function updateList(
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to update lists')
|
||||
}
|
||||
@@ -751,7 +752,7 @@ export async function searchItems(query: string, listId?: string) {
|
||||
}
|
||||
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to search items')
|
||||
}
|
||||
@@ -878,7 +879,7 @@ export async function getItemsByFilter(
|
||||
) {
|
||||
try {
|
||||
// Get current user session
|
||||
const session = await auth()
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.user?.id) {
|
||||
throw new Error('Unauthorized: Please log in to filter items')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user