-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.js
More file actions
22 lines (22 loc) · 745 Bytes
/
admin.js
File metadata and controls
22 lines (22 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module.exports = function(req, res, con, next){
// console.log('Cookies: ', req.cookies);
// console.log('HASH: ', req.cookies.hash);
if (req.cookies.id == undefined || req.cookies.hash == undefined) {
console.log('ERROR User not found');
res.redirect('/login');
return false;
};
con.query(
`SELECT * FROM user WHERE id='${req.cookies.id}' AND hash='${req.cookies.hash}'`,
function (error, result) {
if (error) reject(error);
if (result.length == 0) {
console.log('ERROR User not found');
res.redirect('/login');
} else {
next();
// callback();
// res.render(pathToRender, {});
}
});
}