-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.js
34 lines (30 loc) · 1.11 KB
/
router.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var utils = require('./utils.js');
module.exports = function(router, passport) {
router.route('/login')
.get(function(req, res) {
res.sendFile(__dirname+'/index.html');
})
.post(passport.authenticate('local-login',
{
successRedirect: '/login-otp',
failureRedirect: '/login'
}));
router.route('/login-otp')
.all(function(req, res, next) {
utils.isLoggedIn(req, res, next)
})
.get(function(req, res) {
res.sendFile(__dirname+'/otp.html');
})
.post(passport.authenticate('totp', {/*successRedirect: '/cloud',*/ failureRedirect: '/login-otp'}),
function(req, res) {
req.session.secondFactor = 'totp'
res.redirect('/cloud/')
});
router.route('/logout')
.get(function(req, res) {
req.session.secondFactor = '';
req.logout();
res.redirect('/login');
});
};