all files / express-stormpath/lib/helpers/ assert-org-mapped-to-app.js

25% Statements 2/8
0% Branches 0/4
0% Functions 0/4
25% Lines 2/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                             
'use strict';
 
function assertOrganizationIsMappedToApplication(organization, application, cb) {
  application.getAccountStoreMappings(function (err, mappings) {
    if (err) {
      return cb(err);
    }
 
    mappings.some(function (mapping, next) {
      next(organization && mapping.accountStore.href === organization.href);
    }, function (hasMatch) {
      cb(null, hasMatch);
    });
  });
}
 
module.exports = assertOrganizationIsMappedToApplication;