|
|
|
|
@ -226,11 +226,13 @@ app.use('/restricted', restrictedRoutes)
|
|
|
|
|
restrictedRoutes.all('/', function(req, res, next) { |
|
|
|
|
res.header("Access-Control-Allow-Origin", "*") |
|
|
|
|
res.header("Access-Control-Allow-Headers", "X-Requested-With") |
|
|
|
|
let hostname = os.hostname() |
|
|
|
|
res.setHeader('HOSTNAME', hostname) |
|
|
|
|
console.log(hostname) |
|
|
|
|
next() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
restrictedRoutes.use(function (req, res, next) { |
|
|
|
|
res.setHeader('HOSTNAME', os.hostname()) |
|
|
|
|
if (req.cookies.token) { |
|
|
|
|
jwt.verify(req.cookies.token, secret, function (err, decoded) { |
|
|
|
|
if (err) { |
|
|
|
|
@ -262,6 +264,12 @@ restrictedRoutes.get('/', (req, res) => {
|
|
|
|
|
console.log(JSON.stringify({secret:'You have access to restricted contents!'})) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
restrictedRoutes.get('/hostname', (req, res) => { |
|
|
|
|
let hostname = {hostname: os.hostname()} |
|
|
|
|
res.status(200).json(hostname) |
|
|
|
|
console.log(JSON.stringify(hostname)) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// // Restricted route root stupid
|
|
|
|
|
// const restrictedRoutes = express.Router()
|
|
|
|
|
// app.use('/restricted', restrictedRoutes)
|
|
|
|
|
|