authelia/src/lib/routes.js

35 lines
831 B
JavaScript
Raw Normal View History

2016-12-10 07:47:58 +07:00
var first_factor = require('./routes/first_factor');
2017-01-21 23:41:06 +07:00
var second_factor = require('./routes/second_factor');
var verify = require('./routes/verify');
var objectPath = require('object-path');
2016-12-10 07:47:58 +07:00
module.exports = {
login: serveLogin,
logout: serveLogout,
2017-01-21 23:41:06 +07:00
verify: verify,
first_factor: first_factor,
second_factor: second_factor
2016-12-10 07:47:58 +07:00
}
function serveLogin(req, res) {
if(!(objectPath.has(req, 'session.auth_session'))) {
req.session.auth_session = {};
req.session.auth_session.first_factor = false;
req.session.auth_session.second_factor = false;
}
2017-01-21 23:41:06 +07:00
res.render('login');
2016-12-10 07:47:58 +07:00
}
function serveLogout(req, res) {
var redirect_param = req.query.redirect;
var redirect_url = redirect_param || '/';
2017-01-21 23:41:06 +07:00
req.session.auth_session = {
first_factor: false,
second_factor: false
}
res.redirect(redirect_url);
2016-12-10 07:47:58 +07:00
}