imports/vx/client/code/vxapp.js
/**
     * Find the list of domain objects associated with a supplied user ID.
     *
     * @param {object} userId User ID whose domains are to be returned.
     * @param {string} tenantId Optional tenant ID to filter results.
     * @return {array} Array of domain objects augmented with domain.
     */
Find the list of domain objects associated with a supplied user ID.
@param {object} userId User ID whose domains are to be returned.
@param {string} tenantId Optional tenant ID to filter results.
@return {array} Array of domain objects augmented with domain.
Find the list of domain objects associated with a supplied user ID . @param { object } userId User ID whose domains are to be returned . @param { string } tenantId Optional tenant ID to filter results . @return { array } Array of domain objects augmented with domain .
findUserDomainList(userId, tenantId) {
        let user = Meteor.users.findOne(userId)
        if (!user) {
            OLog.error("vxapp.js findUserDomainList unable to find userId=" + userId)
            return
        }
        if (!tenantId && !Util.isPreference("ALL_MEMBERS_AND_DOMAINS")) {
            tenantId = Util.getCurrentTenantId(Meteor.userId())
        }
        let tenantIdsVisible = Util.getTenantIds(Meteor.userId())
        let domainIdsVisible = Util.getDomainIds(Meteor.userId())
        let domainArray = []
        user.profile.domains.forEach(userDomain => {
            if (!Util.isPreference("ALL_MEMBERS_AND_DOMAINS")) {
                if (!_.contains(domainIdsVisible, userDomain.domainId)) {
                    return
                }
            }
            userDomain.domain = Domains.findOne( { _id : userDomain.domainId } )
            if (!userDomain.domain) {
                return
            }
            if (!Util.isDomainActive(userDomain.domain)) {
                return
            }
            if (tenantId && userDomain.domain.tenant !== tenantId) {
                return
            }
            if (!Util.isPreference("ALL_MEMBERS_AND_DOMAINS")) {
                if (!_.contains(tenantIdsVisible, userDomain.domain.tenant)) {
                    return
                }
            }
            domainArray.push(userDomain)
        })
        return domainArray
    }
findUserDomainList ( userId , tenantId ) { let user = Meteor . users . findOne ( userId ) if ( ! user ) { OLog . error ( "vxapp.js findUserDomainList unable to find userId=" + userId ) return } if ( ! tenantId && ! Util . isPreference ( "ALL_MEMBERS_AND_DOMAINS" ) ) { tenantId = Util . getCurrentTenantId ( Meteor . userId ( ) ) } let tenantIdsVisible = Util . getTenantIds ( Meteor . userId ( ) ) let domainIdsVisible = Util . getDomainIds ( Meteor . userId ( ) ) let domainArray = [ ] user . profile . domains . forEach ( userDomain => { if ( ! Util . isPreference ( "ALL_MEMBERS_AND_DOMAINS" ) ) { if ( ! _ . contains ( domainIdsVisible , userDomain . domainId ) ) { return } } userDomain . domain = Domains . findOne ( { _id : userDomain . domainId } ) if ( ! userDomain . domain ) { return } if ( ! Util . isDomainActive ( userDomain . domain ) ) { return } if ( tenantId && userDomain . domain . tenant !== tenantId ) { return } if ( ! Util . isPreference ( "ALL_MEMBERS_AND_DOMAINS" ) ) { if ( ! _ . contains ( tenantIdsVisible , userDomain . domain . tenant ) ) { return } } domainArray . push ( userDomain ) } ) return domainArray }
Find the list of domain objects associated with a supplied user ID.
Find the list of domain objects associated with a supplied user ID .
// Hide domains that we don't have access to: //OLog.error("vxapp.js findUserDomainList email=" + Util.getUserEmail(user._id) + " has reference to non-existent domainId=" + userDomain.domainId) // If a tenant ID as supplied, us it to filter the results: // Hide domains from foreign teams: