Remove basic admin area
This commit is contained in:
parent
6c1ec0ff2d
commit
1a4805bfe9
11
app.js
11
app.js
|
@ -56,14 +56,15 @@ class Nodezzarella {
|
|||
var routes = require("./lib/router");
|
||||
log.info("HTTP server listening on port", config.appPort);
|
||||
log.info("Application ready");
|
||||
app.use(cookieParser()); // read cookies (needed for auth)
|
||||
app.use(bodyParser.urlencoded({ extended: false })); // get information from url-encoded data
|
||||
app.use(bodyParser.json()); // get information from html forms
|
||||
app.set('trust proxy', 1);
|
||||
app.use(cookieParser());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.json());
|
||||
app.use(session({
|
||||
secret: 'Nodezzarella',
|
||||
resave: false,
|
||||
resave: true,
|
||||
saveUninitialized: true,
|
||||
cookie: { secure: true }
|
||||
cookie: { secure: false, maxAge: 3600*24*31 }
|
||||
}))
|
||||
app.use(config.webroot || "/", routes);
|
||||
app.use(function(req, res, next) {
|
||||
|
|
|
@ -34,55 +34,6 @@ router.get("/", function(req, res){
|
|||
});
|
||||
});
|
||||
|
||||
router.get("/admin/", function(req, res){
|
||||
var categories = new Categories();
|
||||
if(req.session.authenticated === true){
|
||||
res.redirect('/admin/dashboard')
|
||||
}
|
||||
else{
|
||||
categories.getNav().then(data => {
|
||||
fs.readFile('./views/admin/login.hbs', 'utf-8', (error, source) => {
|
||||
var template = hbs.compile(source);
|
||||
res.setHeader("Content-type", "text/html");
|
||||
var tplData = {
|
||||
"blogName": config.siteTitle,
|
||||
"title": config.siteHomeTitle,
|
||||
"nav": data,
|
||||
"content": source,
|
||||
};
|
||||
res.render('templateAdmin.hbs', tplData);
|
||||
});
|
||||
}).catch(err => {
|
||||
log.debug(err);
|
||||
res.setHeader("Content-type", "text/plain");
|
||||
res.end("erreur");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/admin/", function(req, res){
|
||||
if(req.body.login && req.body.login === config.login && req.body.password && req.body.password === config.password){
|
||||
req.session.authenticated = true;
|
||||
res.redirect('/admin/dashboard');
|
||||
|
||||
}
|
||||
else{
|
||||
res.redirect('/admin/');
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/admin/dashboard", function(req, res){
|
||||
log.debug(req.session);
|
||||
if(req.session.authenticated === true){
|
||||
res.setHeader("Content-type", "text/plain");
|
||||
res.end("erreur");
|
||||
}
|
||||
else{
|
||||
res.redirect('/admin/');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
router.get("/:uri/", function(req, res){
|
||||
var categories = new Categories();
|
||||
Promise.all([
|
||||
|
|
Reference in New Issue