How to create new user? #347
rafaelrodrigosilveira
started this conversation in
General
Replies: 1 comment
-
I suggest some workaround - simple script for adding users and import db from "../src/db/db";
import { User } from "../src/db/types";
import { parseArgs } from "util";
const { values, positionals } = parseArgs({
args: Bun.argv,
options: {
email: {
type: 'string',
short: 'e',
},
password: {
type: 'string',
short: 'p',
},
},
strict: true,
allowPositionals: true,
});
const existingUser = db.query("SELECT * FROM users WHERE email = ?").get(values.email);
if (existingUser) {
console.log(`Email used`);
process.exit(1);
}
const savedPassword = await Bun.password.hash(values.password);
db.query("INSERT INTO users (email, password) VALUES (?, ?)").run(values.email, savedPassword);
const user = db.query("SELECT * FROM users WHERE email = ?").as(User).get(values.email);
if (!user) {
console.log("Failed to create user.");
process.exit(2);
}
console.log("User created"); Put this script to To remove user just use : You can automate it as you like, I'm good with bash. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to create new user? I have the installation admin user. But I wanna to create the new user to others peoples. How ti create?
Beta Was this translation helpful? Give feedback.
All reactions