feathers-authentication
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -85,4 +85,3 @@ # Migrating to 1.0 | ||
// The services you are setting the `entity` param for need to be registered before authentication | ||
app.use('/users', memory()) | ||
.configure(auth(app.get('authentication'))) | ||
app.configure(auth(app.get('authentication'))) | ||
.configure(jwt()) | ||
@@ -94,3 +93,4 @@ .configure(local()) | ||
Strategy: FacebookStrategy | ||
})); | ||
})) | ||
.use('/users', memory()); | ||
@@ -97,0 +97,0 @@ // Authenticate the user using the a JWT or |
@@ -193,4 +193,4 @@ 'use strict'; | ||
isUpdateEntitySetup = true; | ||
entityService.on('updated', _updateEntity2.default); | ||
entityService.on('patched', _updateEntity2.default); | ||
entityService.on('updated', (0, _updateEntity2.default)(app)); | ||
entityService.on('patched', (0, _updateEntity2.default)(app)); | ||
} | ||
@@ -197,0 +197,0 @@ }; |
'use strict'; | ||
module.exports = function updateEntity(entity, meta) { | ||
var app = meta.app; | ||
module.exports = function (app) { | ||
return function (entity) { | ||
var authConfig = app.get('auth'); | ||
var idField = app.service(authConfig.service).id; | ||
var authConfig = app.get('auth'); | ||
var idField = app.service(authConfig.service).id; | ||
if (!idField) { | ||
console.error('The adapter for the ' + authConfig.service + ' service does not add an `id` property to the service. It needs to be updated to do so.'); | ||
idField = entity.hasOwnProperty('id') ? 'id' : '_id'; | ||
} | ||
if (!idField) { | ||
console.error('The adapter for the ' + authConfig.service + ' service does not add an `id` property to the service. It needs to be updated to do so.'); | ||
idField = entity.hasOwnProperty('id') ? 'id' : '_id'; | ||
} | ||
var entityId = entity[idField]; | ||
var socketMap = void 0; | ||
var entityId = entity[idField]; | ||
var socketMap = void 0; | ||
if (app.io) { | ||
socketMap = app.io.sockets.sockets; | ||
} | ||
if (app.primus) { | ||
socketMap = app.primus.connections; | ||
} | ||
if (app.io) { | ||
socketMap = app.io.sockets.sockets; | ||
} | ||
if (app.primus) { | ||
socketMap = app.primus.connections; | ||
} | ||
Object.keys(socketMap).forEach(function (socketId) { | ||
var socket = socketMap[socketId]; | ||
var feathers = socket.feathers || socket.request.feathers; | ||
var socketEntity = feathers && feathers[authConfig.entity]; | ||
Object.keys(socketMap).forEach(function (socketId) { | ||
var socket = socketMap[socketId]; | ||
var feathers = socket.feathers || socket.request.feathers; | ||
var socketEntity = feathers && feathers[authConfig.entity]; | ||
if (socketEntity) { | ||
var socketEntityId = socketEntity[idField]; | ||
if (socketEntity) { | ||
var socketEntityId = socketEntity[idField]; | ||
if ('' + entityId === '' + socketEntityId) { | ||
(function () { | ||
// Need to assign because of external references | ||
Object.assign(socketEntity, entity); | ||
if ('' + entityId === '' + socketEntityId) { | ||
(function () { | ||
// Need to assign because of external references | ||
Object.assign(socketEntity, entity); | ||
// Delete any removed entity properties | ||
var entityProps = new Set(Object.keys(entity)); | ||
Object.keys(socketEntity).filter(function (prop) { | ||
return !entityProps.has(prop); | ||
}).forEach(function (prop) { | ||
return delete socketEntity[prop]; | ||
}); | ||
})(); | ||
// Delete any removed entity properties | ||
var entityProps = new Set(Object.keys(entity)); | ||
Object.keys(socketEntity).filter(function (prop) { | ||
return !entityProps.has(prop); | ||
}).forEach(function (prop) { | ||
return delete socketEntity[prop]; | ||
}); | ||
})(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "feathers-authentication", | ||
"description": "Add Authentication to your FeathersJS app.", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"homepage": "https://github.com/feathersjs/feathers-authentication", | ||
@@ -6,0 +6,0 @@ "main": "lib/", |
Sorry, the diff of this file is too big to display
291737
1233