diff --git a/VERSION.txt b/VERSION.txt index dc6ffb7..b66feb2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -204.0.0 \ No newline at end of file +205.0.0 \ No newline at end of file diff --git a/src/app/api/admin/data_migration/import/route.ts b/src/app/api/admin/data_migration/import/route.ts index 4b9dce9..56ec7ac 100644 --- a/src/app/api/admin/data_migration/import/route.ts +++ b/src/app/api/admin/data_migration/import/route.ts @@ -165,11 +165,8 @@ export async function POST(req: NextRequest) { const userData = importData.data.userData; for (const username in userData) { const user = userData[username]; - - // 重新注册用户(包含密码)- 仅用于旧版用户 - if (user.password && !importData.data.usersV2?.find((u: any) => u.username === username)) { - await db.registerUser(username, user.password); - } + await db.createUserV2(username, user.password,user.role,user.tags); + // 导入播放记录 if (user.playRecords) { @@ -201,13 +198,6 @@ export async function POST(req: NextRequest) { } } } - - // 标记播放记录已迁移(新导入的数据直接使用hash结构) - const storage = (db as any).storage; - if (storage && typeof storage.client?.hSet === 'function') { - const userInfoKey = `user:${username}:info`; - await storage.client.hSet(userInfoKey, 'playrecord_migrated', 'true'); - } } return NextResponse.json({ diff --git a/src/app/api/admin/user/route.ts b/src/app/api/admin/user/route.ts index bc07401..01d5124 100644 --- a/src/app/api/admin/user/route.ts +++ b/src/app/api/admin/user/route.ts @@ -165,9 +165,6 @@ export async function POST(request: NextRequest) { // 使用新版本创建用户 await db.createUserV2(targetUsername!, targetPassword, 'user', tags); - // 同时在旧版本存储中创建(保持兼容性) - await db.registerUser(targetUsername!, targetPassword); - // 不再更新配置,因为用户已经存储在新版本中 // 构造一个虚拟的targetEntry用于后续逻辑 targetEntry = { @@ -298,8 +295,6 @@ export async function POST(request: NextRequest) { // 使用新版本修改密码(SHA256加密) await db.changePasswordV2(targetUsername!, targetPassword); - // 同时更新旧版本(保持兼容性) - await db.changePassword(targetUsername!, targetPassword); break; } case 'deleteUser': { @@ -327,8 +322,6 @@ export async function POST(request: NextRequest) { // 只删除V2存储中的用户 await db.deleteUserV2(targetUsername!); - // 同时删除旧版本(保持兼容性) - await db.deleteUser(targetUsername!); break; } diff --git a/src/app/api/admin/users/route.ts b/src/app/api/admin/users/route.ts index 9e644c8..0964e46 100644 --- a/src/app/api/admin/users/route.ts +++ b/src/app/api/admin/users/route.ts @@ -71,36 +71,13 @@ export async function GET(request: NextRequest) { ); } - // 回退到配置中的用户列表 - const configUsers = adminConfig.UserConfig.Users || []; - const total = configUsers.length; - - // 排序:站长始终在第一位,其他用户按用户名排序 - const sortedUsers = [...configUsers].sort((a, b) => { - if (a.username === process.env.USERNAME) return -1; - if (b.username === process.env.USERNAME) return 1; - return a.username.localeCompare(b.username); - }); - - // 分页 - const paginatedUsers = sortedUsers.slice(offset, offset + limit); - - // 转换为统一格式 - const users = paginatedUsers.map((u) => ({ - username: u.username, - role: u.role, - banned: u.banned || false, - tags: u.tags, - created_at: 0, // 配置中没有创建时间 - })); - return NextResponse.json( { - users, - total, + users: [], + total: 0, page, limit, - totalPages: Math.ceil(total / limit), + totalPages: 0, }, { headers: { diff --git a/src/app/api/auth/oidc/complete-register/route.ts b/src/app/api/auth/oidc/complete-register/route.ts index f95652d..098986e 100644 --- a/src/app/api/auth/oidc/complete-register/route.ts +++ b/src/app/api/auth/oidc/complete-register/route.ts @@ -124,10 +124,6 @@ export async function POST(request: NextRequest) { // 检查用户名是否已存在(优先使用新版本) let userExists = await db.checkUserExistV2(username); - if (!userExists) { - // 回退到旧版本检查 - userExists = await db.checkUserExist(username); - } if (userExists) { return NextResponse.json( { error: '用户名已存在' }, diff --git a/src/app/api/login/route.ts b/src/app/api/login/route.ts index b10c9d9..6ee58f4 100644 --- a/src/app/api/login/route.ts +++ b/src/app/api/login/route.ts @@ -231,19 +231,6 @@ export async function POST(req: NextRequest) { pass = await db.verifyUserV2(username, password); userRole = userInfoV2.role; isBanned = userInfoV2.banned; - } else { - // 回退到旧版本验证 - try { - pass = await db.verifyUser(username, password); - // 从配置中获取角色和封禁状态 - if (user) { - userRole = user.role; - isBanned = user.banned || false; - } - } catch (err) { - console.error('数据库验证失败', err); - return NextResponse.json({ error: '数据库错误' }, { status: 500 }); - } } // 检查用户是否被封禁 diff --git a/src/components/AIChatPanel.tsx b/src/components/AIChatPanel.tsx index 4bb5e66..8b20d7d 100644 --- a/src/components/AIChatPanel.tsx +++ b/src/components/AIChatPanel.tsx @@ -329,7 +329,7 @@ export default function AIChatPanel({

) : (
- + {message.content}
diff --git a/src/lib/db.ts b/src/lib/db.ts index 0e2b109..6584fb3 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -132,11 +132,7 @@ export class DbManager { return favorite !== null; } - // ---------- 用户相关(旧版本,保持兼容) ---------- - async registerUser(userName: string, password: string): Promise { - await this.storage.registerUser(userName, password); - } - + async verifyUser(userName: string, password: string): Promise { return this.storage.verifyUser(userName, password); } diff --git a/src/lib/redis-base.db.ts b/src/lib/redis-base.db.ts index 9742cc5..f8a4384 100644 --- a/src/lib/redis-base.db.ts +++ b/src/lib/redis-base.db.ts @@ -492,11 +492,6 @@ export abstract class BaseRedisStorage implements IStorage { return `u:${user}:pwd`; } - async registerUser(userName: string, password: string): Promise { - // 简单存储明文密码,生产环境应加密 - await this.withRetry(() => this.client.set(this.userPwdKey(userName), password)); - } - async verifyUser(userName: string, password: string): Promise { const stored = await this.withRetry(() => this.client.get(this.userPwdKey(userName)) diff --git a/src/lib/types.ts b/src/lib/types.ts index 96a7040..3159881 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -53,7 +53,6 @@ export interface IStorage { migrateFavorites(userName: string): Promise; // 用户相关 - registerUser(userName: string, password: string): Promise; verifyUser(userName: string, password: string): Promise; // 检查用户是否存在(无需密码) checkUserExist(userName: string): Promise; diff --git a/src/lib/upstash.db.ts b/src/lib/upstash.db.ts index 4a727f5..fb75710 100644 --- a/src/lib/upstash.db.ts +++ b/src/lib/upstash.db.ts @@ -393,11 +393,6 @@ export class UpstashRedisStorage implements IStorage { return `u:${user}:pwd`; } - async registerUser(userName: string, password: string): Promise { - // 简单存储明文密码,生产环境应加密 - await withRetry(() => this.client.set(this.userPwdKey(userName), password)); - } - async verifyUser(userName: string, password: string): Promise { const stored = await withRetry(() => this.client.get(this.userPwdKey(userName))