finished reset password & other changes

This commit is contained in:
2024-04-24 22:37:55 +03:00
parent b1ad7b5c3e
commit 53cadc289a
58 changed files with 1520 additions and 349 deletions

View File

@@ -5,10 +5,12 @@ import db from '@/lib/db'
import authConfig from '@/auth.config'
import { getUserById } from '@/data/user'
import { AUTH_ERROR_URL, AUTH_LOGIN_URL } from '@/config/routes'
import { getCurrentLocale } from '@/locales/server'
import { type loc } from '@/config/locales'
declare module 'next-auth' {
interface Session {
user: { role: UserRole }
user: { role: UserRole, locale: loc }
}
}
@@ -47,6 +49,7 @@ export const {
return true
},
async session ({ token, session }) {
if (token.sub && session.user) {
session.user.id = token.sub
}
@@ -55,6 +58,8 @@ export const {
session.user.role = token.role as UserRole
}
session.user.locale = getCurrentLocale()
return session
},
async jwt ({ token }) {