add initial
This commit is contained in:
26
cli/cli.ts
Normal file
26
cli/cli.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import argon2 from "argon2";
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const username = args[0];
|
||||
const password = args[1];
|
||||
|
||||
if (!username || !password) {
|
||||
console.error("Usage: node cli.js <username>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const hash = await argon2.hash(password, {
|
||||
type: argon2.argon2id,
|
||||
memoryCost: 19456,
|
||||
timeCost: 2,
|
||||
parallelism: 1,
|
||||
});
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
await prisma.user.deleteMany({ where: { username } });
|
||||
await prisma.user.create({ data: { username, password: hash } });
|
||||
}
|
||||
|
||||
main();
|
Reference in New Issue
Block a user