This commit is contained in:
2025-07-08 19:03:34 +08:00
parent caa855717f
commit 789ba73f81
4 changed files with 5 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ export const adminController = {
username: admin.username, username: admin.username,
role: admin.isAdmin ? 'admin' : 'user' role: admin.isAdmin ? 'admin' : 'user'
}, },
process.env.JWT_SECRET!, "pandora",
{ expiresIn: '24h' } { expiresIn: '24h' }
); );

View File

@@ -8,7 +8,7 @@ import type { Secret, SignOptions } from 'jsonwebtoken';
// Generate JWT token // Generate JWT token
function generateToken(userId: string): string { function generateToken(userId: string): string {
const secret = process.env.JWT_SECRET; const secret = "pandora";
if (!secret) { if (!secret) {
throw new Error('JWT_SECRET is not configured'); throw new Error('JWT_SECRET is not configured');
} }
@@ -303,7 +303,7 @@ export const authController = {
} }
try { try {
const decoded = jwt.verify(refreshToken, process.env.JWT_SECRET!) as any; const decoded = jwt.verify(refreshToken, "pandora") as any;
const session = await prisma.session.findFirst({ const session = await prisma.session.findFirst({
where: { where: {

View File

@@ -28,7 +28,7 @@ export const authenticateToken = async (
} }
const token = authHeader.substring(7); const token = authHeader.substring(7);
const decoded = jwt.verify(token, process.env.JWT_SECRET!) as any; const decoded = jwt.verify(token, "pandora") as any;
// 检查用户是否存在 // 检查用户是否存在
const user = await prisma.user.findUnique({ const user = await prisma.user.findUnique({

View File

@@ -26,7 +26,7 @@ export async function authMiddleware(
const token = authHeader.substring(7); const token = authHeader.substring(7);
console.log('验证token:', { token: token.substring(0, 20) + '...' }) console.log('验证token:', { token: token.substring(0, 20) + '...' })
const decoded = jwt.verify(token, process.env.JWT_SECRET!) as any; const decoded = jwt.verify(token, "pandora") as any;
console.log('JWT解码成功:', { userId: decoded.userId }) console.log('JWT解码成功:', { userId: decoded.userId })
// Check if session exists and is valid // Check if session exists and is valid