Fixed server lint
This commit is contained in:
parent
83a94dbdff
commit
42607a8e65
@ -1,21 +1,21 @@
|
|||||||
var qs = require('qs');
|
const qs = require('qs'); // eslint-disable-line import/no-extraneous-dependencies
|
||||||
var request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
function githubToken(clientId, code) {
|
function githubToken(clientId, code) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
request({
|
request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'https://github.com/login/oauth/access_token',
|
url: 'https://github.com/login/oauth/access_token',
|
||||||
qs: {
|
qs: {
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
client_secret: process.env.GITHUB_SECRET,
|
client_secret: process.env.GITHUB_SECRET,
|
||||||
code: code
|
code,
|
||||||
},
|
},
|
||||||
}, function(err, res, body) {
|
}, (err, res, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
var token = qs.parse(body).access_token;
|
const token = qs.parse(body).access_token;
|
||||||
if (token) {
|
if (token) {
|
||||||
resolve(token);
|
resolve(token);
|
||||||
} else {
|
} else {
|
||||||
@ -25,11 +25,9 @@ function githubToken(clientId, code) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.githubToken = function (req, res) {
|
exports.githubToken = (req, res) => {
|
||||||
githubToken(req.query.clientId, req.query.code)
|
githubToken(req.query.clientId, req.query.code)
|
||||||
.then(function (token) {
|
.then(
|
||||||
res.send(token);
|
token => res.send(token),
|
||||||
}, function (err) {
|
err => res.status(400).send(err ? err.message || err.toString() : 'bad_code'));
|
||||||
res.status(400).send(err ? err.message || err.toString() : 'bad_code');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ module.exports = (app, serveV4) => {
|
|||||||
// Enable CORS for fonts
|
// Enable CORS for fonts
|
||||||
if (/\.(eot|ttf|woff|svg)$/.test(req.url)) {
|
if (/\.(eot|ttf|woff|svg)$/.test(req.url)) {
|
||||||
res.header('Access-Control-Allow-Origin', '*');
|
res.header('Access-Control-Allow-Origin', '*');
|
||||||
};
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -33,9 +33,7 @@ module.exports = (app, serveV4) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serve callback.html in /app
|
// Serve callback.html in /app
|
||||||
app.get('/oauth2/callback', function(req, res) {
|
app.get('/oauth2/callback', (req, res) => res.sendFile(path.join(__dirname, '../static/oauth2/callback.html')));
|
||||||
res.sendFile(path.join(__dirname, '../static/oauth2/callback.html'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Serve static resources
|
// Serve static resources
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
Loading…
Reference in New Issue
Block a user