root user

This commit is contained in:
archer
2023-07-30 12:53:32 +08:00
parent 502d8d8c73
commit 40200c7c71

View File

@@ -67,18 +67,24 @@ async function initRootUser() {
const rootUser = await User.findOne({
username: 'root'
});
if (rootUser) {
console.log('root user already exists');
return;
}
const psw = process.env.DEFAULT_ROOT_PSW || '123456';
if (rootUser) {
await User.findOneAndUpdate(
{ username: 'root' },
{
password: createHashPassword(psw)
}
);
} else {
await User.create({
username: 'root',
password: createHashPassword(psw),
balance: 100 * PRICE_SCALE
balance: 999999 * PRICE_SCALE
});
}
console.log(`create root user success`, {
console.log(`root user init:`, {
username: 'root',
password: psw
});