2016-12-10 07:47:58 +07:00
|
|
|
|
2017-01-19 07:01:37 +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');
|
2017-01-19 07:01:37 +07:00
|
|
|
|
2016-12-10 07:47:58 +07:00
|
|
|
module.exports = {
|
2017-01-19 07:01:37 +07:00
|
|
|
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) {
|
2017-01-21 23:41:06 +07:00
|
|
|
req.session.auth_session = {};
|
|
|
|
req.session.auth_session.first_factor = false;
|
|
|
|
req.session.auth_session.second_factor = false;
|
|
|
|
|
2016-12-17 08:06:40 +07:00
|
|
|
res.render('login');
|
2016-12-10 07:47:58 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
function serveLogout(req, res) {
|
2016-12-18 01:36:41 +07:00
|
|
|
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
|
|
|
|
}
|
2016-12-18 01:36:41 +07:00
|
|
|
res.redirect(redirect_url);
|
2016-12-10 07:47:58 +07:00
|
|
|
}
|
2016-12-18 01:36:41 +07:00
|
|
|
|