Files
digicraft-be/reset_test_password.ts
Fahri Can Seçer 80dcf4d04a
Some checks failed
Deploy Backend / deploy (push) Has been cancelled
main
2026-02-05 01:29:22 +03:00

33 lines
851 B
TypeScript

import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcryptjs';
const prisma = new PrismaClient();
async function upsertUser() {
const email = 'test@example.com';
const password = 'password123';
const role = 'ADMIN';
console.log(`Upserting user: ${email}`);
const salt = await bcrypt.genSalt(10);
const passwordHash = await bcrypt.hash(password, salt);
try {
const user = await prisma.user.upsert({
where: { email },
update: { passwordHash, role },
create: { email, passwordHash, role }
});
console.log(`✅ SUCCESS! User ${email} is ready.`);
console.log(`🔑 Password: ${password}`);
} catch (e) {
console.error("❌ Error upserting user:", e);
} finally {
await prisma.$disconnect();
}
}
upsertUser();