|
|
|
|
@ -9,6 +9,7 @@ const Prometheus = require('prom-client');
|
|
|
|
|
const fs = require('file-system'); |
|
|
|
|
const marked = require('marked'); |
|
|
|
|
const jwt = require('jsonwebtoken'); |
|
|
|
|
const bodyParser= require('body-parser'); |
|
|
|
|
|
|
|
|
|
// database connection (with retries)
|
|
|
|
|
const options = { |
|
|
|
|
@ -84,7 +85,8 @@ app.get('/metrics2', function(req, res){
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// JWT generation
|
|
|
|
|
app.use(express.json()); |
|
|
|
|
// app.use(express.json());
|
|
|
|
|
app.use(bodyParser.urlencoded({ extended: false })); |
|
|
|
|
app.post('/token', function(req, res){ |
|
|
|
|
console.log(req.body); |
|
|
|
|
console.log(req.body.username); |
|
|
|
|
@ -94,15 +96,18 @@ app.post('/token', function(req, res){
|
|
|
|
|
var token = jwt.sign(req.body, 'wowmuchsecretveryhiddenwow'); |
|
|
|
|
console.log(token); |
|
|
|
|
// res.json(token);
|
|
|
|
|
res.status(200).json({ |
|
|
|
|
success: 'SUCCESS! You\'re in.', |
|
|
|
|
token: token |
|
|
|
|
}); |
|
|
|
|
// res.status(200).json({
|
|
|
|
|
// success: 'SUCCESS! You\'re in.',
|
|
|
|
|
// token: token
|
|
|
|
|
// });
|
|
|
|
|
res.redirect('http://localhost/yay.html'); |
|
|
|
|
} else { |
|
|
|
|
res.status(500).send('this is not the password I expected'); |
|
|
|
|
// res.status(500).send('this is not the password I expected');
|
|
|
|
|
res.redirect('http://localhost/nay.html'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
res.status(500).send('this is not the user I want');; |
|
|
|
|
// res.status(500).send('this is not the user I want');
|
|
|
|
|
res.redirect('http://localhost/nay.html'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|