-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateUser.js
More file actions
27 lines (21 loc) · 884 Bytes
/
CreateUser.js
File metadata and controls
27 lines (21 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const readline = require("readline");
const MongoClient = require("mongodb").MongoClient;
const sha256 = require("js-sha256");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("Insert your email: ", (email) => {
rl.question("Insert your password: ", (password) => {
console.log(`Creating an account with these informations: ${email} ${password}`)
MongoClient.connect("mongodb://localhost:27017/game-server-panel")
.then((ConnectedMongoClient) => {
const Users = ConnectedMongoClient.db("game-server-panel").collection("Users");
Users.insertOne({email: sha256(email), password: sha256(password)}, (error) => {
error ? console.log(error) && process.exit(1) : console.log("User created successfully");
rl.close();
process.exit(0);
})
});
})
});