This commit is contained in:
@@ -3,32 +3,11 @@ import { PrismaAdapter } from "@auth/prisma-adapter";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
import { db } from "@/lib/db";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { Role } from "@prisma/client";
|
||||
import { authConfig } from "@/auth.config";
|
||||
|
||||
export const { handlers, auth, signIn, signOut } = NextAuth({
|
||||
...authConfig,
|
||||
adapter: PrismaAdapter(db) as any,
|
||||
session: { strategy: "jwt" },
|
||||
pages: {
|
||||
signIn: "/login",
|
||||
},
|
||||
callbacks: {
|
||||
async jwt({ token, user }) {
|
||||
if (user) {
|
||||
token.id = user.id;
|
||||
token.role = (user as { role: Role }).role;
|
||||
token.mustChangePassword = (user as { mustChangePassword?: boolean }).mustChangePassword ?? false;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
async session({ session, token }) {
|
||||
if (token && session.user) {
|
||||
session.user.id = token.id as string;
|
||||
session.user.role = token.role as Role;
|
||||
session.user.mustChangePassword = token.mustChangePassword as boolean;
|
||||
}
|
||||
return session;
|
||||
},
|
||||
},
|
||||
providers: [
|
||||
Credentials({
|
||||
name: "credentials",
|
||||
|
||||
Reference in New Issue
Block a user