@feathersjs/authentication-local
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Change Log | ||
## [v1.1.0](https://github.com/feathersjs/authentication-local/tree/v1.1.0) (2018-01-23) | ||
[Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.4...v1.1.0) | ||
**Closed issues:** | ||
- protect hook attempts to map through 'result.data' on all service methods. [\#53](https://github.com/feathersjs/authentication-local/issues/53) | ||
- Protect hook should check for toJSON [\#48](https://github.com/feathersjs/authentication-local/issues/48) | ||
**Merged pull requests:** | ||
- Use .toJSON if available [\#55](https://github.com/feathersjs/authentication-local/pull/55) ([daffl](https://github.com/daffl)) | ||
- Only map data for find method [\#54](https://github.com/feathersjs/authentication-local/pull/54) ([daffl](https://github.com/daffl)) | ||
- Update @feathersjs/authentication-jwt to the latest version π [\#52](https://github.com/feathersjs/authentication-local/pull/52) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
- Update mocha to the latest version π [\#51](https://github.com/feathersjs/authentication-local/pull/51) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
## [v1.0.4](https://github.com/feathersjs/authentication-local/tree/v1.0.4) (2018-01-03) | ||
@@ -4,0 +19,0 @@ [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.3...v1.0.4) |
@@ -36,41 +36,21 @@ const hasher = require('../utils/hash'); | ||
let data; | ||
const dataIsArray = Array.isArray(context.data); | ||
const data = dataIsArray ? context.data : [ context.data ]; | ||
// make sure we actually have password fields | ||
if (Array.isArray(context.data)) { | ||
data = context.data.filter(item => { | ||
return item.hasOwnProperty(field); | ||
}); | ||
} else if (context.data[field]) { | ||
data = context.data; | ||
} | ||
// If the data doesn't have a password field | ||
// then don't attempt to hash it. | ||
if (data === undefined || (Array.isArray(data) && !data.length)) { | ||
debug(`'${field}' field is missing. Skipping hashPassword hook.`); | ||
return Promise.resolve(context); | ||
} | ||
if (Array.isArray(data)) { | ||
debug(`Hashing passwords.`); | ||
return Promise.all(data.map(item => { | ||
return Promise.all(data.map(item => { | ||
if (item.hasOwnProperty(field)) { | ||
return hashPw(item[field]).then(hashedPassword => { | ||
item[field] = hashedPassword; | ||
return item; | ||
return Object.assign(item, { | ||
[field]: hashedPassword | ||
}); | ||
}); | ||
})) | ||
.then(results => { | ||
context.data = results; | ||
return Promise.resolve(context); | ||
}); | ||
} | ||
} | ||
debug(`Hashing password.`); | ||
return hashPw(data[field]).then(hashedPassword => { | ||
context.data[field] = hashedPassword; | ||
return Promise.resolve(context); | ||
return item; | ||
})).then(results => { | ||
context.data = dataIsArray ? results : results[0]; | ||
return context; | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "@feathersjs/authentication-local", | ||
"description": "Local authentication strategy for @feathers/authentication", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"homepage": "https://github.com/feathersjs/authentication-local", | ||
@@ -71,5 +71,5 @@ "main": "lib/", | ||
"semistandard": "^12.0.0", | ||
"sinon": "^4.0.0", | ||
"sinon-chai": "^2.11.0" | ||
"sinon": "^5.0.0", | ||
"sinon-chai": "^3.0.0" | ||
} | ||
} |
26526
239