From 7a0ec1402e192bb1d9aa844980db9e181b981ea2 Mon Sep 17 00:00:00 2001 From: Jonathon Hill Date: Fri, 27 Jul 2018 15:42:29 -0400 Subject: [PATCH] eslint passing --- examples/mongodb/model.js | 8 ++++---- examples/postgresql/model.js | 8 ++++---- test/integration/index_test.js | 17 ++++++++--------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/examples/mongodb/model.js b/examples/mongodb/model.js index 1dc6a1f..cd992df 100755 --- a/examples/mongodb/model.js +++ b/examples/mongodb/model.js @@ -90,16 +90,16 @@ module.exports.saveToken = function(token, client, user) { // Can't just chain `lean()` to `save()` as we did with `findOne()` elsewhere. Instead we use `Promise` to resolve the data. return new Promise( function(resolve,reject){ accessToken.save(function(err,data){ - if( err ) reject( err ); - else resolve( data ); + if( err ) {reject( err );} + else {resolve( data );} }) ; }).then(function(saveResult){ // `saveResult` is mongoose wrapper object, not doc itself. Calling `toJSON()` returns the doc. - saveResult = saveResult && typeof saveResult == 'object' ? saveResult.toJSON() : saveResult; + saveResult = saveResult && typeof saveResult === 'object' ? saveResult.toJSON() : saveResult; // Unsure what else points to `saveResult` in oauth2-server, making copy to be safe var data = new Object(); - for( var prop in saveResult ) data[prop] = saveResult[prop]; + for( var prop in saveResult ) {data[prop] = saveResult[prop];} // /oauth-server/lib/models/token-model.js complains if missing `client` and `user`. Creating missing properties. data.client = data.clientId; diff --git a/examples/postgresql/model.js b/examples/postgresql/model.js index ef95404..72aa03c 100644 --- a/examples/postgresql/model.js +++ b/examples/postgresql/model.js @@ -27,7 +27,7 @@ module.exports.getAccessToken = function(bearerToken) { * Get client. */ -module.exports.getClient = function *(clientId, clientSecret) { +module.exports.getClient = function(clientId, clientSecret) { return pg.query('SELECT client_id, client_secret, redirect_uri FROM oauth_clients WHERE client_id = $1 AND client_secret = $2', [clientId, clientSecret]) .then(function(result) { var oAuthClient = result.rows[0]; @@ -48,7 +48,7 @@ module.exports.getClient = function *(clientId, clientSecret) { * Get refresh token. */ -module.exports.getRefreshToken = function *(bearerToken) { +module.exports.getRefreshToken = function(bearerToken) { return pg.query('SELECT access_token, access_token_expires_on, client_id, refresh_token, refresh_token_expires_on, user_id FROM oauth_tokens WHERE refresh_token = $1', [bearerToken]) .then(function(result) { return result.rowCount ? result.rows[0] : false; @@ -59,7 +59,7 @@ module.exports.getRefreshToken = function *(bearerToken) { * Get user. */ -module.exports.getUser = function *(username, password) { +module.exports.getUser = function(username, password) { return pg.query('SELECT id FROM users WHERE username = $1 AND password = $2', [username, password]) .then(function(result) { return result.rowCount ? result.rows[0] : false; @@ -70,7 +70,7 @@ module.exports.getUser = function *(username, password) { * Save token. */ -module.exports.saveAccessToken = function *(token, client, user) { +module.exports.saveAccessToken = function(token, client, user) { return pg.query('INSERT INTO oauth_tokens(access_token, access_token_expires_on, client_id, refresh_token, refresh_token_expires_on, user_id) VALUES ($1, $2, $3, $4)', [ token.accessToken, token.accessTokenExpiresOn, diff --git a/test/integration/index_test.js b/test/integration/index_test.js index 91f91b7..0567ad1 100644 --- a/test/integration/index_test.js +++ b/test/integration/index_test.js @@ -108,9 +108,9 @@ describe('ExpressOAuthServer', function() { request(app.listen()) .get('/') .set('Authorization', 'Bearer foobar') - .expect(200, function(err, res){ - spy.called.should.be.True(); - done(err); + .expect(200, function(err){ + spy.called.should.be.true(); + done(err); }); }); }); @@ -146,9 +146,9 @@ describe('ExpressOAuthServer', function() { .post('/?state=foobiz') .set('Authorization', 'Bearer foobar') .send({ client_id: 12345, response_type: 'code' }) - .expect(302, function(err, res){ - spy.called.should.be.True(); - done(err); + .expect(302, function(err){ + spy.called.should.be.true(); + done(err); }); }); @@ -243,8 +243,8 @@ describe('ExpressOAuthServer', function() { .post('/') .send('client_id=foo&client_secret=bar&grant_type=password&username=qux&password=biz') .expect({ access_token: 'foobar', token_type: 'Bearer' }) - .expect(200, function(err, res){ - spy.called.should.be.True(); + .expect(200, function(err){ + spy.called.should.be.true(); done(err); }); }); @@ -261,7 +261,6 @@ describe('ExpressOAuthServer', function() { return { accessToken: 'foobar', client: {}, user: {} }; } }; - var spy = sinon.spy(); var oauth = new ExpressOAuthServer({ model: model, continueMiddleware: true }); app.use(oauth.token());