module.exports.getUser = (req, res) => {
if (req.isAuthenticated() && req.user.role == 'user')
res.render('user');
}
module.exports.postChangeRole = (req, res) => {
console.log(req.body);
pg.connect(connectionString, function (err, client, done) {
console.log(req);
if (err) {
return console.error('error feetching client from pool', err);
}
client.query('UPDATE items SET role=($1), change=($2) WHERE name=($3)', [req.body.role,
req.body.role == 'user' ? 'true' : 'false', req.body.name]);
done();
});
}