mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 08:47:40 -05:00
Add All Systems List
This commit is contained in:
@@ -3,6 +3,7 @@ const System = require("../models/system");
|
||||
const SystemStat = require("../models/system_stat");
|
||||
const Talkgroup = require("../models/talkgroup");
|
||||
const Group = require("../models/group");
|
||||
const User = require("../models/user");
|
||||
const crypto = require("crypto");
|
||||
|
||||
exports.isLoggedIn = function (req, res, next) {
|
||||
@@ -12,6 +13,27 @@ exports.isLoggedIn = function (req, res, next) {
|
||||
|
||||
// -------------------------------------------
|
||||
|
||||
exports.listUserSystems = async function (req,res,next) {
|
||||
if (!req.user.admin) {
|
||||
res.status(401);
|
||||
res.json({ success: false, message: "Not Authorized" });
|
||||
return;
|
||||
}
|
||||
const users = await User.find({}, "_id email firstName lastName lastLogin");
|
||||
let list = [];
|
||||
console.log(users);
|
||||
for (let index = 0; index < users.length; index++) {
|
||||
let user = users[index].toObject();
|
||||
const userId = new mongoose.Types.ObjectId(user._id);
|
||||
const systems = await System.find({ userId: userId }, "name shortName description systemType city state county country lastActive");
|
||||
|
||||
user["systems"] = systems;
|
||||
list.push(user);
|
||||
}
|
||||
res.json(list);
|
||||
return;
|
||||
}
|
||||
|
||||
exports.listAllSystems = async function (req, res, next) {
|
||||
if (!req.user.admin) {
|
||||
res.status(401);
|
||||
|
||||
Reference in New Issue
Block a user