评论与评分系统
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bun
|
||||
import 'dotenv/config';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { prisma } from '../src/lib/prisma';
|
||||
|
||||
async function main() {
|
||||
const [username, newPassword] = process.argv.slice(2);
|
||||
if (!username || !newPassword) {
|
||||
console.error('Usage: bun scripts/resetPassword.ts <username> <newPassword>');
|
||||
process.exit(1);
|
||||
}
|
||||
const user = await prisma.user.findUnique({ where: { username } });
|
||||
if (!user) {
|
||||
console.error(`User not found: ${username}`);
|
||||
process.exit(2);
|
||||
}
|
||||
const hash = await bcrypt.hash(newPassword, 10);
|
||||
await prisma.user.update({ where: { id: user.id }, data: { password: hash } });
|
||||
console.log(`Password reset for user: ${username}`);
|
||||
}
|
||||
|
||||
main().finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user