UI Admin aproape finalizat

This commit is contained in:
andrei-mihnea-cerbu
2024-04-03 02:09:12 +03:00
parent fb957a6f97
commit af8c295d75
134 changed files with 5014 additions and 1045 deletions
+22
View File
@@ -0,0 +1,22 @@
const fs = require('fs');
const path = require('path');
const checkSession = (req, res, next) => {
const configPath = path.join(__dirname, '..', 'config', 'credentials.json');
const configFile = fs.readFileSync(configPath);
const config = JSON.parse(configFile);
const userEmail = req.cookies.email;
if (req.path === '/login') {
next();
} else {
if (userEmail && decodeURIComponent(userEmail) === config.email) {
next();
} else {
res.redirect('/login');
}
}
}
module.exports = checkSession