New Passwordprotection

This commit is contained in:
2021-11-03 17:47:08 +01:00
parent bb13976b52
commit 02d64a7056
5 changed files with 86 additions and 48 deletions

View File

@@ -19,43 +19,55 @@ router.use("/sbr_ue", sbr_ue);
/*
var svgCaptcha = require('svg-captcha');
*/
router.get('/login', function(req, res) {
var captcha = svgCaptcha.create({color: true});
/*var captcha = svgCaptcha.create({color: true});
req.session.captcha = captcha.text;
req.session.captcha_raw = captcha;
res.render('login', { captcha: captcha.text });
req.session.captcha_raw = captcha;*/
res.render('login'/*, { captcha: captcha.text }*/);
});
router.get('/captcha', function (req, res) {
/*router.get('/captcha', function (req, res) {
res.type('svg');
res.status(200).send(req.session.captcha_raw.data);
});
});*/
var passwords = {
"bibelseminar": "markusevangelium"
};
router.post('/login', function(req, res){
console.log(req.body.captcha);
/*console.log(req.body.captcha);
console.log(req.session.captcha);
console.log(req.body.as_presentation);
console.log(Boolean(req.body.as_presentation));
console.log(Boolean(req.body.as_presentation));*/
var pathname = "/";
if(req.session.startdest)
pathname = req.session.startdest;
console.log(pathname);
if(req.body.captcha === req.session.captcha)
/*console.log(pathname);
console.log(passwords);
console.log(req.body.username);*/
var password = passwords[req.body.username];
/*console.log(password)*/
/*if(req.body.captcha === req.session.captcha)*/
if(req.body.password === password)
{
console.log("OK");
req.session.regenerate(function(){
req.session.no_robot = true;
req.session.as_presentation = Boolean(req.body.as_presentation);
/*req.session.as_presentation = Boolean(req.body.as_presentation);*/
res.redirect(pathname);
});
}
else
res.redirect("http://www.erzbistum-bamberg.de");
res.redirect("https://www.erzbistum-bamberg.de");
});
router.get('/logout', function(req, res){
@@ -65,6 +77,6 @@ router.get('/logout', function(req, res){
res.redirect('/login');
});
});
*/
module.exports = router;