all files / express-stormpath/lib/helpers/ requires-organization-resolution.js

100% Statements 4/4
20% Branches 1/5
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                    35×   35×            
'use strict';
 
var getHost = require('./get-host');
 
/**
* Determines whether organization resolution is required for multi-tenancy
* subdomain flow. Used only in the subdomain multi-tenancy resolution flow.
*
* @param {Object} req - HTTP request
* @return {Boolean} - Whether organization resolution is required
*/
module.exports = function (req) {
  var config = req.app.get('stormpathConfig');
 
  return config.web.multiTenancy.enabled
    && config.web.multiTenancy.strategy === 'subdomain'
    && config.web.domainName
    && getHost(req, true) !== config.web.domainName
    && !req.organization;
};