blob: 280fd74d90e5c528ade248f621cb24ad893bfd62 (
plain) (
blame)
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
|
const bcrypt = require('bcrypt');
const moment = require('moment');
exports.seed = async db => {
const now = moment.utc().toDate();
const user = await db.table('users').where({ username: process.env.ADMIN_ACCOUNT }).first();
if (user) return;
try {
const hash = await bcrypt.hash(process.env.ADMIN_PASSWORD, 10);
await db.table('users').insert({
username: process.env.ADMIN_ACCOUNT,
password: hash,
passwordEditedAt: now,
createdAt: now,
editedAt: now,
enabled: true,
isAdmin: true
});
console.log();
console.log('=========================================================');
console.log('== Successfully created the admin account. ==');
console.log('=========================================================');
console.log('== Run `pm2 start pm2.json` to start the service ==');
console.log('=========================================================');
console.log();
} catch (error) {
console.error(error);
}
};
|