add client/admin pages, show info and created admin api and server actions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import NextAuth from 'next-auth'
|
||||
import NextAuth, { type DefaultSession } from 'next-auth'
|
||||
import { UserRole } from '@prisma/client'
|
||||
import { PrismaAdapter } from '@auth/prisma-adapter'
|
||||
import db from '@/lib/db'
|
||||
@@ -9,9 +9,16 @@ import { getCurrentLocale } from '@/locales/server'
|
||||
import { type loc } from '@/config/locales'
|
||||
import { getTwoFactorConfirmationByUserId } from '@/data/two-factor-confirmation'
|
||||
|
||||
export type ExtendedUser = DefaultSession['user'] & {
|
||||
role: UserRole,
|
||||
locale: loc,
|
||||
isTwoFactorEnabled?: boolean,
|
||||
image?: string
|
||||
}
|
||||
|
||||
declare module 'next-auth' {
|
||||
interface Session {
|
||||
user: { role: UserRole, locale: loc, image?: string }
|
||||
user: ExtendedUser
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +74,10 @@ export const {
|
||||
session.user.role = token.role as UserRole
|
||||
}
|
||||
|
||||
if (session.user) {
|
||||
session.user.isTwoFactorEnabled = token.isTwoFactorEnabled as boolean
|
||||
}
|
||||
|
||||
session.user.locale = getCurrentLocale()
|
||||
|
||||
return session
|
||||
@@ -79,6 +90,7 @@ export const {
|
||||
if (!existingUser) return token
|
||||
|
||||
token.role = existingUser.role
|
||||
token.isTwoFactorEnabled = existingUser.isTwoFactorEnabled
|
||||
|
||||
return token
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user