You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is the produce of a brief talk on the feathers slack help channel with @eddyystop, the problem appear on the hook.data param, as described on the documentation, a service should have a data param considered as a single object or an array, when using the service as a batch service like : app.service('users').create([userobject1, userobject2])
The hook addVerification will not work in this case, it will simply add the token properties after the array, we need to correlate what we already have in hashPassword hook in feathers-authentication like :
if (Array.isArray(hook.data)) {
// make sure we actually have password fields
var dataToCheck = [].concat(hook.data);
dataToCheck.filter(function (item) {
return item.hasOwnProperty(options.passwordField);
});
if (dataToCheck.length > 0) {
// set it to the array so we can iterate later on it
password = hook.data;
}
} else {
password = hook.data[options.passwordField];
}
Instead we got :
module.exports.addVerification = function (path) {
return function (hook) {
utils.checkContext(hook, 'before', 'create');
return Promise.resolve().then(function () {
return hook.app.service(path || 'authManagement').create({ action: 'options' });
}).then(function (options) {
return Promise.all([options, getLongToken(options.longTokenLen), getShortToken(options.shortTokenLen, options.shortTokenDigits)]);
}).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 3),
options = _ref2[0],
longToken = _ref2[1],
shortToken = _ref2[2];
hook.data.isVerified = false;
hook.data.verifyExpires = Date.now() + options.delay;
hook.data.verifyToken = longToken;
hook.data.verifyShortToken = shortToken;
hook.data.verifyChanges = {};
return hook;
}).catch(function (err) {
throw new errors.GeneralError(err);
});
};
};`
`
Expected behavior would be to test hook.data if it's an array, and iterate on it.
The text was updated successfully, but these errors were encountered:
This issue is the produce of a brief talk on the feathers slack help channel with @eddyystop, the problem appear on the hook.data param, as described on the documentation, a service should have a data param considered as a single object or an array, when using the service as a batch service like :
app.service('users').create([userobject1, userobject2])
The hook addVerification will not work in this case, it will simply add the token properties after the array, we need to correlate what we already have in hashPassword hook in feathers-authentication like :
Instead we got :
The text was updated successfully, but these errors were encountered: