New Passwordprotection
parent
bb13976b52
commit
02d64a7056
14
app.js
14
app.js
|
|
@ -9,7 +9,7 @@ var parseurl = require('parseurl')
|
|||
|
||||
var index = require('./routes/index');
|
||||
|
||||
/*const session = require('express-session');*/
|
||||
const session = require('express-session');
|
||||
const os = require('os');
|
||||
|
||||
var app = express();
|
||||
|
|
@ -21,8 +21,8 @@ app.set('view engine', 'pug');
|
|||
// uncomment after placing your favicon in /public
|
||||
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
|
||||
|
||||
/*app.use(session({
|
||||
secret: 'keyboard cat',
|
||||
app.use(session({
|
||||
secret: 'markusevangleium',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
}));
|
||||
|
|
@ -39,15 +39,15 @@ app.use(function restrict(req, res, next)
|
|||
else
|
||||
{
|
||||
req.session.startdest = pathname;
|
||||
var hostname = os.hostname();
|
||||
/*var hostname = os.hostname();
|
||||
if(hostname === 'pc-familie.halieus.de' || hostname === 'pc.peter.halieus.de') {
|
||||
req.session.as_presentation = true;
|
||||
next();
|
||||
}
|
||||
else
|
||||
res.redirect('/login');
|
||||
else*/
|
||||
res.redirect('/login');
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
include mixins_cookies
|
||||
//- include mixins_cookies
|
||||
|
||||
doctype html
|
||||
html(lang='de')
|
||||
|
|
@ -17,13 +17,13 @@ html(lang='de')
|
|||
style.
|
||||
h3 { font-style: italic; font-size: 1.5rem; }
|
||||
|
||||
+cookies_css
|
||||
//- +cookies_css
|
||||
body
|
||||
.container-fluid(style="margin-top: 1rem;")
|
||||
block content
|
||||
|
||||
|
||||
script(src='/javascripts/bootstrap.min.js')
|
||||
|
||||
+cookies_html
|
||||
+cookies_script
|
||||
//-
|
||||
+cookies_html
|
||||
+cookies_script
|
||||
|
|
|
|||
|
|
@ -18,26 +18,49 @@ html(lang='de')
|
|||
p(style="text-align: right;")
|
||||
a(href="http://www.halieus.de/impressum_datenschutz.html" target="_blank") Impressum & Datenschutzerklärung
|
||||
|
||||
p
|
||||
| Auf diesen Seiten finden Sie interessante Informationen zu biblischen Themen.
|
||||
|
||||
|
||||
//- img(src="/captcha", alt="CAPTCHA", style="margin-top: 5px; margin-bottom: 5px;")
|
||||
|
||||
|
||||
.row
|
||||
.col-sm-1
|
||||
button.btn.btn-success.btn-sm(onclick="run_login();")
|
||||
span Weiter ...
|
||||
.row
|
||||
.col-sm-12.small(style="margin-top: 15px;")
|
||||
span
|
||||
| Mit dem Klicken auf <q>Weiter ...</q> wird ein Session-Cookie erzeugt und im Browser bespeichert.
|
||||
br
|
||||
| Außer diesem werden keine weiteren Cookies angelegt, es findet kein Tracking statt und die Seiten sind werbefrei.
|
||||
|
||||
|
||||
|
||||
|
||||
form(method="post", action="/login", role="form", style="margin-top: 15px;", id="login_form")
|
||||
.form-group(style="display: none;")
|
||||
|
||||
.form-group(style="margin-bottom: 25px;")
|
||||
.col-sm-12
|
||||
| Auf diesen Seiten finden Sie interessante Informationen zu biblischen Themen.
|
||||
br
|
||||
| Der Zugriff ist beschränkt auf zugelassene Benutzer.
|
||||
.form-group
|
||||
label.col-sm-1.control-label(for="benutzername")
|
||||
b Benutzername
|
||||
.col-sm-5
|
||||
input.form-control#benutzername(type="text", name="username")
|
||||
.form-group
|
||||
label.col-sm-1.control-label(for="passwort")
|
||||
b Paßwort
|
||||
.col-sm-5
|
||||
input.form-control#passwort(type="password", name="password")
|
||||
|
||||
|
||||
.from-group(style="margin-top: 25px; margin-bottom: 25px;")
|
||||
.col-sm-12
|
||||
| Mit dem Klicken auf <q>Weiter ...</q> wird ein Session-Cookie erzeugt und im Browser bespeichert.
|
||||
br
|
||||
| Außer diesem werden keine weiteren Cookies angelegt, es findet kein Tracking statt und die Seiten sind werbefrei.
|
||||
br
|
||||
| Zum Speichern und Abfragen der Einstellung zum Präsentationsmodus wird der Session-Store genutzt.
|
||||
|
||||
.from-group
|
||||
.col-sm-1
|
||||
button.btn.btn-success.btn-sm
|
||||
//- (onclick="run_login();")
|
||||
span Weiter ...
|
||||
|
||||
//- .form-group(style="display: none;")
|
||||
label.col-sm-1.control-label(for="ID1")
|
||||
b Captcha
|
||||
.col-sm-5
|
||||
|
|
@ -46,7 +69,7 @@ html(lang='de')
|
|||
//- .col-sm-1
|
||||
//- button.btn.btn-success.btn-sm(type="submit")
|
||||
//- span OK
|
||||
.form-check(style="margin-top: 50px;")
|
||||
//- .form-check(style="margin-top: 50px;")
|
||||
.col-sm-5
|
||||
label.form-check-label
|
||||
input.form-check-input(type="checkbox", name="as_presentation")
|
||||
|
|
@ -65,13 +88,15 @@ html(lang='de')
|
|||
span Force Refresh on Back Key Logic
|
||||
|
||||
script.
|
||||
$(function () {
|
||||
if ($('#refreshCheck')[0].checked)
|
||||
/*$(function () {
|
||||
if ($('#refreshCheck')[0].checked) {
|
||||
window.location.reload();
|
||||
}
|
||||
$('#refreshCheck')[0].checked = true;
|
||||
});
|
||||
});*/
|
||||
|
||||
/*
|
||||
function run_login() {
|
||||
$("#captcha").val("!{captcha}");
|
||||
$("#login_form").submit();
|
||||
}
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
include ../../../mixins_cookies
|
||||
//- include ../../../mixins_cookies
|
||||
include ../../../mixins_headline_nav
|
||||
|
||||
doctype html
|
||||
|
|
@ -16,7 +16,7 @@ html(lang='de')
|
|||
script(src='/javascripts/slide-utils.js')
|
||||
script(src='/javascripts/popper.min.js')
|
||||
|
||||
+cookies_css
|
||||
//- +cookies_css
|
||||
body
|
||||
+headline
|
||||
block headline
|
||||
|
|
@ -41,6 +41,7 @@ html(lang='de')
|
|||
|
||||
|
||||
+body_presentation_script
|
||||
|
||||
+cookies_html
|
||||
+cookies_script
|
||||
|
||||
//-
|
||||
+cookies_html
|
||||
+cookies_script
|
||||
|
|
|
|||
Loading…
Reference in New Issue