forked from appsecco/dvna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
68 lines (55 loc) · 1.71 KB
/
main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var router = require('express').Router()
var vulnDict = require('../config/vulns')
var authHandler = require('../core/authHandler')
module.exports = function (passport) {
router.get('/', authHandler.isAuthenticated, function (req, res) {
res.redirect('/learn')
})
router.get('/login', authHandler.isNotAuthenticated, function (req, res) {
res.render('login')
})
router.get('/learn/vulnerability/:vuln', authHandler.isAuthenticated, function (req, res) {
res.render('vulnerabilities/layout', {
vuln: req.params.vuln,
vuln_title: vulnDict[req.params.vuln],
vuln_scenario: req.params.vuln + '/scenario',
vuln_description: req.params.vuln + '/description',
vuln_reference: req.params.vuln + '/reference',
vulnerabilities:vulnDict
}, function (err, html) {
if (err) {
console.log(err)
res.status(404).send('404')
} else {
res.send(html)
}
})
})
router.get('/learn', authHandler.isAuthenticated, function (req, res) {
res.render('learn',{vulnerabilities:vulnDict})
})
router.get('/register', authHandler.isNotAuthenticated, function (req, res) {
res.render('register')
})
router.get('/logout', function (req, res) {
req.logout();
res.redirect('/');
})
router.get('/forgotpw', function (req, res) {
res.render('forgotpw')
})
router.get('/resetpw', authHandler.resetPw)
router.post('/login', passport.authenticate('login', {
successRedirect: '/learn',
failureRedirect: '/login',
failureFlash: true
}))
router.post('/register', passport.authenticate('signup', {
successRedirect: '/learn',
failureRedirect: '/register',
failureFlash: true
}))
router.post('/forgotpw', authHandler.forgotPw)
router.post('/resetpw', authHandler.resetPwSubmit)
return router
}