Skip to content

Commit

Permalink
Fix crash when no entityService is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
compwright committed Jun 18, 2017
1 parent 402a00b commit 9c58b35
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/socket/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function handleSocketCallback (promise, callback) {
export default function setupSocketHandler (app, options, { feathersParams, provider, emit, disconnect }) {
const authSettings = app.get('authentication') || app.get('auth');
const service = app.service(authSettings.path);
const entityService = app.service(authSettings.service);
let entityService;
if (authSettings.service) {
entityService = app.service(authSettings.service);
}
let isUpdateEntitySetup = false;

return function (socket) {
Expand Down Expand Up @@ -152,7 +155,7 @@ export default function setupSocketHandler (app, options, { feathersParams, prov
socket.on('logout', logout);

// Only bind the handlers on receiving the first socket connection.
if (!isUpdateEntitySetup) {
if (!isUpdateEntitySetup && entityService) {
isUpdateEntitySetup = true;
entityService.on('updated', updateEntity);
entityService.on('patched', updateEntity);
Expand Down

1 comment on commit 9c58b35

@Zalasanjay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was also facing that issue and i have solved by applying this code i got solution.
so i request you to merge this code in master so that we can use it by default.

Please sign in to comment.