Skip to content

Commit

Permalink
(pouchdb/express-pouchdb#297) - fix bulkDocs() password hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-de-vries committed Mar 19, 2016
1 parent 85cc7f6 commit 811913b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/writewrappers.js
Expand Up @@ -40,4 +40,6 @@ function modifyDoc(db, doc) {
}

exports.post = exports.put;
exports.bulkDocs = createBulkDocsWrapper(modifyDoc);
exports.bulkDocs = createBulkDocsWrapper(function (doc, args) {
return modifyDoc(args.db, doc);
});
12 changes: 10 additions & 2 deletions test/functionality.js
Expand Up @@ -170,8 +170,16 @@ describe('SyncAuthTests', () => {
err.message.should.contain('Malformed');
});

afterEach(async () => {
should.not.exist(await db.stopUsingAsAuthenticationDB());
it('should hash plain-text passwords in bulkDocs', async () => {
// https://github.com/pouchdb/express-pouchdb/issues/297
const resp = await db.bulkDocs({docs: [{
_id: "org.couchdb.user:testuser",
name:"testuser",
password:"test",
type:"user",
roles:[]
}]});
should.not.exist((await db.get(resp[0].id)).password);
});
});

Expand Down

0 comments on commit 811913b

Please sign in to comment.