courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 13:50:28 +02:00
parent 95ea63db2f
commit 0fbc339447

View File

@ -1,5 +1,6 @@
import { NextAuthOptions } from 'next-auth';
import { NextAuthOptions, User } from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';
import { JWT } from 'next-auth/jwt';
export const authOptions: NextAuthOptions = {
providers: [
@ -15,18 +16,54 @@ export const authOptions: NextAuthOptions = {
}
// TODO: Implement actual authentication logic
// For now, generate a unique ID based on email
const userId = Buffer.from(credentials.email).toString('base64');
return {
id: '1',
id: userId,
email: credentials.email,
name: credentials.email.split('@')[0],
};
first_name: credentials.email.split('@')[0],
last_name: '',
username: credentials.email,
role: ['user']
} satisfies User;
}
})
],
session: {
strategy: 'jwt',
maxAge: 30 * 24 * 60 * 60, // 30 days
},
jwt: {
maxAge: 30 * 24 * 60 * 60, // 30 days
},
secret: process.env.NEXTAUTH_SECRET,
pages: {
signIn: '/login',
signIn: '/courrier/login',
},
callbacks: {
async jwt({ token, user }) {
if (user) {
token.id = user.id;
token.email = user.email;
token.first_name = user.first_name;
token.last_name = user.last_name;
token.username = user.username;
token.role = user.role;
}
return token;
},
async session({ session, token }) {
if (token) {
session.user.id = token.id as string;
session.user.email = token.email as string;
session.user.first_name = token.first_name as string;
session.user.last_name = token.last_name as string;
session.user.username = token.username as string;
session.user.role = token.role as string[];
}
return session;
}
}
};