-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-user.ts
40 lines (37 loc) · 877 Bytes
/
create-user.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as db from "./db";
import { hashPassword } from "./user";
const register = async function(name: string, email: string, password: string) {
let profile = await db.createUser(
db.NETWORK_PASSWORD,
null,
name,
null,
null,
null
);
console.log("created user:", profile);
password = await hashPassword(password);
console.log("updating password...");
profile = await db.updateUser(profile.id, {
email: email,
name: null,
picture: null,
password: password,
});
console.log("done.");
};
const args = process.argv.slice(2);
if (args.length !== 3) {
console.log("expected name, email, password, but got:", args);
process.exit(1);
}
(async () => {
try {
await db.connect();
await register(args[0], args[1], args[2]);
process.exit(0);
} catch (e) {
console.error(e);
process.exit(1);
}
})();