added server management
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
const User = require('../model/user.model')
|
||||
const Key = require("../model/key.model");
|
||||
|
||||
const regexp = /^\S*$/;
|
||||
|
||||
|
||||
async function userList(code) {
|
||||
return await User.findAll()
|
||||
@@ -15,6 +19,23 @@ function makeAdmin(userId) {
|
||||
});
|
||||
}
|
||||
|
||||
async function delUser(id) {
|
||||
User.findOne({where: { id: id}}).then((result) => {
|
||||
|
||||
if (result && regexp.test(id)) {
|
||||
result.destroy()
|
||||
.then(() => {
|
||||
console.log('user ' + id + ' deleted from database')
|
||||
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
makeAdmin
|
||||
makeAdmin,
|
||||
delUser,
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user