Skip to content

Commit

Permalink
eslint passing
Browse files Browse the repository at this point in the history
  • Loading branch information
compwright committed Sep 13, 2018
1 parent 63b10c8 commit 7a0ec14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions examples/mongodb/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions examples/postgresql/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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,
Expand Down
17 changes: 8 additions & 9 deletions test/integration/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});
Expand All @@ -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());
Expand Down

0 comments on commit 7a0ec14

Please sign in to comment.