Skip to content

Commit

Permalink
fix(accounts): ignore non-hoodie account docs in accounts.findAll()
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Mar 7, 2017
1 parent b59366b commit 3f40085
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/accounts/find-all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = findAllAccount

var isHoodieAccountDoc = require('../utils/is-hoodie-account-doc')
var toAccount = require('../utils/doc-to-account')

function findAllAccount (state, options) {
Expand All @@ -12,10 +13,14 @@ function findAllAccount (state, options) {

.then(function (response) {
options = options || {}
return response.rows.map(function (row) {
return toAccount(row.doc, {
includeProfile: options.include === 'profile'
return response.rows
.filter(function (row) {
return isHoodieAccountDoc(row.doc)
})
.map(function (row) {
return toAccount(row.doc, {
includeProfile: options.include === 'profile'
})
})
})
})
}
7 changes: 7 additions & 0 deletions lib/utils/is-hoodie-account-doc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = isHoodieAccountDoc

var findIdInRoles = require('./find-id-in-roles')

function isHoodieAccountDoc (doc) {
return !!findIdInRoles(doc.roles)
}

0 comments on commit 3f40085

Please sign in to comment.