diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8b21b96..e647059 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -90,7 +90,7 @@ model Chat { model Message { id String @id @default(auto()) @map("_id") @db.ObjectId - message String + text String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 0000000..7974308 --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1,9 @@ +export { default } from "next-auth/middleware" + +export const config = { + matcher: [ + "/dashboard", + "/profile", + '/chat/:path*' + ] +} \ No newline at end of file diff --git a/src/pages/api/auth/[...nextauth].ts b/src/pages/api/auth/[...nextauth].ts index 1e6524e..104fa83 100644 --- a/src/pages/api/auth/[...nextauth].ts +++ b/src/pages/api/auth/[...nextauth].ts @@ -41,6 +41,13 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) { return await NextAuth(req, res, { providers, session: {strategy: 'jwt'}, + pages: { + signIn: '/login', + signOut: '/auth/signout', + error: '/auth/error', + verifyRequest: '/auth/verify-request', + newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest) + }, secret: process.env.NEXTAUTH_SECRET, callbacks: { async session({session, token}: { session: any; token: any }) {