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