Commit 40200c7c by archer

root user

parent 502d8d8c
...@@ -67,18 +67,24 @@ async function initRootUser() { ...@@ -67,18 +67,24 @@ async function initRootUser() {
const rootUser = await User.findOne({ const rootUser = await User.findOne({
username: 'root' username: 'root'
}); });
const psw = process.env.DEFAULT_ROOT_PSW || '123456';
if (rootUser) { if (rootUser) {
console.log('root user already exists'); await User.findOneAndUpdate(
return; { username: 'root' },
{
password: createHashPassword(psw)
}
);
} else {
await User.create({
username: 'root',
password: createHashPassword(psw),
balance: 999999 * PRICE_SCALE
});
} }
const psw = process.env.DEFAULT_ROOT_PSW || '123456';
await User.create({
username: 'root',
password: createHashPassword(psw),
balance: 100 * PRICE_SCALE
});
console.log(`create root user success`, { console.log(`root user init:`, {
username: 'root', username: 'root',
password: psw password: psw
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment