Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13 from feathersjs/fix-linting
Browse files Browse the repository at this point in the history
Fix linting
  • Loading branch information
marshallswain committed Dec 13, 2016
2 parents cf2f612 + b687aab commit 47075d6
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
9 changes: 4 additions & 5 deletions example/app.js
@@ -1,18 +1,17 @@
const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const primus = require('feathers-primus');
const hooks = require('feathers-hooks');
const memory = require('feathers-memory');
const bodyParser = require('body-parser');
const errors = require('feathers-errors');
const errorHandler = require('feathers-errors/handler');
const auth = require('feathers-authentication');
const local = require('feathers-authentication-local');
const jwt = require('feathers-authentication-jwt');
const path = require('path');

function customizeJWTPayload() {
return function(hook) {
function customizeJWTPayload () {
return function (hook) {
hook.data.payload = {
id: hook.params.user.id
};
Expand All @@ -32,7 +31,7 @@ app.configure(rest())
.configure(local())
.configure(jwt())
.use('/users', memory())
.use('/', feathers.static(__dirname + '/public'))
.use('/', feathers.static(path.join(__dirname, '/public')))
.use(errorHandler());

app.service('authentication').hooks({
Expand Down
4 changes: 2 additions & 2 deletions example/primus-client.js
Expand Up @@ -45,6 +45,6 @@ client.authenticate({
client.set('user', user);
console.log('User', client.get('user'));
})
.catch(function(error){
.catch(function (error) {
console.error('Error authenticating!', error);
});
});
6 changes: 3 additions & 3 deletions example/rest-client.js
Expand Up @@ -2,7 +2,7 @@
// Most of the code is the same for the browser with the exception
// of how modules are imported and configured. It depends on how you choose
// to load them. Refer to the client section of docs.feathersjs.com for more detail.
//
//
const feathers = require('feathers/client');
const rest = require('feathers-rest/client');
const superagent = require('superagent');
Expand Down Expand Up @@ -33,6 +33,6 @@ client.authenticate({
client.set('user', user);
console.log('User', client.get('user'));
})
.catch(function(error){
.catch(function (error) {
console.error('Error authenticating!', error);
});
});
4 changes: 2 additions & 2 deletions example/socketio-client.js
Expand Up @@ -34,6 +34,6 @@ client.authenticate({
client.set('user', user);
console.log('User', client.get('user'));
})
.catch(function(error){
.catch(function (error) {
console.error('Error authenticating!', error);
});
});
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,7 +34,7 @@
"changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"",
"compile": "rimraf lib/ && babel -d lib/ src/",
"watch": "babel --watch -d lib/ src/",
"lint": "semistandard src/**/*.js test/**/*.js --fix",
"lint": "semistandard --fix",
"mocha": "mocha --opts mocha.opts",
"coverage": "istanbul cover _mocha -- --opts mocha.opts",
"test": "npm run compile && npm run lint && npm run coverage",
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Expand Up @@ -5,13 +5,13 @@ const defaults = {
header: 'authorization',
cookie: 'feathers-jwt',
storageKey: 'feathers-jwt',
jwtStrategy: 'jwt',
jwtStrategy: 'jwt',
path: '/authentication',
entity: 'user',
service: 'users'
};

export default function init(config = {}) {
export default function init (config = {}) {
const options = Object.assign({}, defaults, config);

return function () {
Expand Down Expand Up @@ -41,4 +41,4 @@ export default function init(config = {}) {
};
}

init.defaults = defaults;
init.defaults = defaults;
12 changes: 6 additions & 6 deletions src/passport.js
Expand Up @@ -9,7 +9,7 @@ export default class Passport {
if (app.passport) {
throw new Error('You have already registered authentication on this client app instance. You only need to do it once.');
}

this.options = options;
this.app = app;
this.storage = app.get('storage') || this.getStorage(options.storage);
Expand All @@ -22,7 +22,7 @@ export default class Passport {
this.setupSocketListeners();
}

setupSocketListeners() {
setupSocketListeners () {
const app = this.app;
const socket = app.io || app.primus;
const emit = app.io ? 'emit' : 'send';
Expand All @@ -40,7 +40,7 @@ export default class Passport {
if (socket.authenticated) {
const data = {
strategy: this.options.jwtStrategy,
accessToken: app.get('accessToken'),
accessToken: app.get('accessToken')
};
this.authenticateSocket(data, socket, emit)
.then(this.setJWT)
Expand All @@ -61,7 +61,7 @@ export default class Passport {
if (socket.authenticated) {
const data = {
strategy: this.options.jwtStrategy,
accessToken: app.get('accessToken'),
accessToken: app.get('accessToken')
};

this.authenticateSocket(data, socket, emit)
Expand Down Expand Up @@ -93,7 +93,7 @@ export default class Passport {
debug('Socket already connected');
return Promise.resolve(socket);
}

return new Promise((resolve, reject) => {
const connected = app.primus ? 'open' : 'connect';
const disconnect = app.io ? 'disconnect' : 'end';
Expand Down Expand Up @@ -233,7 +233,7 @@ export default class Passport {

try {
let payload = decode(token);

if (this.payloadIsValid(payload)) {
return Promise.resolve(payload);
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Expand Up @@ -47,4 +47,4 @@ describe('Feathers Authentication Client', () => {
expect(client.passport.options.service).to.equal('users');
});
});
});
});

0 comments on commit 47075d6

Please sign in to comment.