forked from vitoc/tellsell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (24 loc) · 1000 Bytes
/
index.js
File metadata and controls
29 lines (24 loc) · 1000 Bytes
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
var restify = require('restify');
let jwt_decode = require('jwt-decode')
let Constants = require('./constants.js');
let authorizationURL = `https://login.microsoftonline.com/${Constants.TENANT_ID}/oauth2/authorize?client_id=${Constants.APPLICATION_ID}&response_type=id_token&redirect_uri=http://localhost:8080/login&response_mode=form_post&scope=openid&state=gustav&nonce=tesla`;
const server = restify.createServer({
name: 'tellsell',
version: '1.0.0'
});
server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());
server.get('/', function (req, res, next) {
res.redirect(authorizationURL, next);
return next();
});
server.post('/login', function (req, res, next) {
let decodedToken = jwt_decode(req.body.id_token);
console.log(decodedToken);
res.send("Login successful");
return next();
});
server.listen(8080, function () {
console.log('%s listening at %s', server.name, server.url);
});