51 lines
923 B
JavaScript
51 lines
923 B
JavaScript
import { PrismaClient } from '@prisma/client'
|
|
import { createHmac } from "crypto"
|
|
import 'dotenv/config'
|
|
|
|
const secret = process.env.PASSWORD_SECRET ? process.env.PASSWORD_SECRET : ""
|
|
|
|
const db = new PrismaClient()
|
|
|
|
const users = [
|
|
"zuma",
|
|
"nicolo",
|
|
"gororeznor",
|
|
"ragdub",
|
|
"onenleir",
|
|
"triskell",
|
|
"anubis",
|
|
"asmolith",
|
|
"izameh",
|
|
"lucie",
|
|
"kellaubz",
|
|
"bertrand",
|
|
"tibalt",
|
|
"jean",
|
|
"mercant",
|
|
"axel",
|
|
"aeddis",
|
|
"demo_a",
|
|
"demo_b",
|
|
"demo_c",
|
|
"demode",
|
|
]
|
|
|
|
async function createUser(username) {
|
|
const email = username + "@example.com"
|
|
const password = username + "123"
|
|
const hashed_password = createHmac('sha256',secret).update(password).digest('hex')
|
|
const admin = true
|
|
|
|
const user = await db.utilisateurice.create({
|
|
data: {
|
|
username,
|
|
password: hashed_password,
|
|
email,
|
|
admin,
|
|
}
|
|
})
|
|
|
|
console.log(user.username)
|
|
}
|
|
|
|
users.forEach(createUser)
|