Feat: Added script to create users and Upgrade Database
This commit is contained in:
parent
3a766620b7
commit
0ea1d4a3e4
4 changed files with 132 additions and 51 deletions
51
app/tools/createUser.mjs
Normal file
51
app/tools/createUser.mjs
Normal file
|
@ -0,0 +1,51 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue