add get and post edit_users
This commit is contained in:
parent
a56e6d4798
commit
3b4afcfcc3
@ -71,6 +71,28 @@ module.exports = function (app, sql, app_cfg, passport, auth) {
|
||||
});
|
||||
});
|
||||
|
||||
// get /show_active_user
|
||||
app.get('/show_active_user', auth.ensureAuthenticated, function(req, res) {
|
||||
sql.db_get_active_clients(function(data) {
|
||||
res.render('show_active_user', {
|
||||
title: 'Verbundene PCs/Benutzer',
|
||||
user: req.user,
|
||||
dataSet: data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// get /show_active_waip
|
||||
app.get('/show_active_waip', auth.ensureAuthenticated, function(req, res) {
|
||||
sql.db_get_active_waips(function(data) {
|
||||
res.render('show_active_waip', {
|
||||
title: 'Akutelle Einsätze',
|
||||
user: req.user,
|
||||
dataSet: data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// get /show_log
|
||||
app.get('/show_log', auth.ensureAuthenticated, function(req, res) {
|
||||
sql.db_get_log(function(data) {
|
||||
@ -82,6 +104,36 @@ module.exports = function (app, sql, app_cfg, passport, auth) {
|
||||
});
|
||||
});
|
||||
|
||||
// get /edit_users
|
||||
app.get('/edit_users', auth.ensureAuthenticated, function(req, res) {
|
||||
sql.db_get_users(function(data) {
|
||||
res.render('edit_users', {
|
||||
title: 'Benutzer und Rechte verwalten',
|
||||
user: req.user,
|
||||
users: data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/edit_users', auth.ensureAuthenticated, function(req, res) {
|
||||
console.log(req.body);
|
||||
if (req.user && req.user.permissions == "admin") {
|
||||
switch (req.body["_method"]) {
|
||||
case "DELETE":
|
||||
deleteUser(req, res);
|
||||
break;
|
||||
case "PUT":
|
||||
editUser(req, res);
|
||||
break;
|
||||
default:
|
||||
createUser(req, res);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
res.redirect('/edit_users');
|
||||
}
|
||||
});
|
||||
|
||||
// get /login
|
||||
app.get('/login', function(req, res) {
|
||||
res.render('login', {
|
||||
@ -116,7 +168,9 @@ module.exports = function (app, sql, app_cfg, passport, auth) {
|
||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||
// render the error page
|
||||
res.status(err.status || 500);
|
||||
res.render('error');
|
||||
res.render('error', {
|
||||
user: req.user
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user