update:add ci cd files ==> do not edit those file

This commit is contained in:
mahyargdz
2024-10-10 21:49:00 +03:30
parent 6fe34708a2
commit 8cf0492c87
464 changed files with 79533 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
const User = require('../models/User')
const _privateAdminInfo = require('./privateAdminData')
const bcrypt = require('bcryptjs')
const database = require('../database')
module.exports.createAdmins = () => {
database.once('open', async cb => {
for (const item of _privateAdminInfo) {
try {
const user = await User.findOne({username: item.username})
if (!user) {
const data = {
username: item.username,
scope: ['admin']
}
// hash password
const salt = await bcrypt.genSalt(10)
const hash = await bcrypt.hash(item.password, salt)
data.password = hash
const newUser = new User(data)
newUser.save(err => {
if (err) console.log(err)
})
}
} catch
(e) {
console.log('Private admin creation has error -- ', e)
}
}
})
}