authelia/src/lib/routes.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-12-10 07:47:58 +07:00
2017-05-21 03:55:37 +07:00
var first_factor = require('./routes/FirstFactor');
2017-01-21 23:41:06 +07:00
var second_factor = require('./routes/second_factor');
2017-01-27 07:20:03 +07:00
var reset_password = require('./routes/reset_password');
2017-01-21 23:41:06 +07:00
var verify = require('./routes/verify');
2017-01-27 07:20:03 +07:00
var u2f_register_handler = require('./routes/u2f_register_handler');
2017-01-29 00:27:54 +07:00
var totp_register = require('./routes/totp_register');
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,
2017-01-27 07:20:03 +07:00
second_factor: second_factor,
reset_password: reset_password,
2017-01-29 00:27:54 +07:00
u2f_register: u2f_register_handler,
totp_register: totp_register,
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;
}
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
}