mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
Cleaned up Admin
This commit is contained in:
@@ -11,11 +11,15 @@ module.exports = function (app, passport) {
|
||||
// serializing, and querying the user record by ID from the database when
|
||||
// deserializing.
|
||||
passport.serializeUser((user, done) => {
|
||||
console.log("passport.serializeUser() - Serializing the user: " + user.id);
|
||||
done(null, user.id)
|
||||
})
|
||||
|
||||
passport.deserializeUser((id, done) => {
|
||||
console.log("passport.deserializeUser() - Trying to deSerialize the user: " + id);
|
||||
User.findById(id, (err, user) => {
|
||||
console.log("passport.deserializeUser() - Found the user: " + user);
|
||||
console.log("passport.deserializeUser() - Err: " + err);
|
||||
done(err, user)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -140,15 +140,19 @@ function csv_import(shortName, filename, callback) {
|
||||
console.error("Error: csv import 2: " + err);
|
||||
callback(err, null);
|
||||
} else {
|
||||
var response = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var row = data[i];
|
||||
row.num = parseInt(row.num);
|
||||
row.tag = row.tag.toLowerCase();
|
||||
row.group = row.group.toLowerCase();
|
||||
var newTg = new Talkgroup();
|
||||
newTg.num = parseInt(row.num);
|
||||
newTg.num = row.num;
|
||||
newTg.alpha = row.alpha;
|
||||
newTg.mode = row.mode;
|
||||
newTg.description = row.description;
|
||||
newTg.tag = row.tag.toLowerCase();
|
||||
newTg.group = row.group.toLowerCase();
|
||||
newTg.tag = row.tag;
|
||||
newTg.group = row.group;
|
||||
newTg.priority = row.priority;
|
||||
newTg.shortName = shortName;
|
||||
|
||||
@@ -158,8 +162,10 @@ function csv_import(shortName, filename, callback) {
|
||||
callback(err, null);
|
||||
}
|
||||
});
|
||||
|
||||
response.push(row);
|
||||
}
|
||||
callback(null, data);
|
||||
callback(null, response);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -242,7 +248,6 @@ exports.fetchTalkgroups = function(req, res, next) {
|
||||
res.json({ success: false, message: err });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json({ success: true, talkgroups: talkgroups });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ function isAdmin(req, res, next) {
|
||||
}
|
||||
|
||||
function isLoggedIn(req, res, next) {
|
||||
console.log(req)
|
||||
if (req.isAuthenticated()) return next();
|
||||
res.status(401).send({
|
||||
success: false,
|
||||
|
||||
Reference in New Issue
Block a user