Skip to content

Commit

Permalink
Fix: use the localUser function in orgsForUser check
Browse files Browse the repository at this point in the history
the orgsForUser publication was broken b/c it was looking at Meteor.user().bitbucket|github
  • Loading branch information
dalehille committed Jun 17, 2020
1 parent a5eaf8b commit cfb01a7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions imports/api/org/server/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import _ from 'lodash';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { Orgs } from '../orgs.js';
import { localUser } from '../../lib/login.js';

Meteor.publish('orgIdByName', function(orgName){
return Orgs.find({ name: orgName }, { _id: 1, name: 1, customSearchableAttrs: 1});
Expand All @@ -29,13 +30,13 @@ Meteor.publish('orgs', function(names){
});

Meteor.publish('orgsForUser', function(){
if(Meteor.user() && (Meteor.user().bitbucket || Meteor.user().github)) {
const orgNames = _.map(Meteor.user().orgs || [], 'name');
return Orgs.find({ name: { $in: orgNames } }, { name: 1, orgYaml: 1, customSearchableAttrs: 1 });
} else {
if(localUser()) {
// local users should be able to see see all orgs with type local
return Orgs.find({ type: 'local' }, { name: 1, customSearchableAttrs: 1 });
}
} else {
const orgNames = _.map(Meteor.user().orgs || [], 'name');
return Orgs.find({ name: { $in: orgNames } }, { name: 1, customSearchableAttrs: 1 });
}
});

Meteor.publish('gheOrg', (orgName)=>{
Expand Down

0 comments on commit cfb01a7

Please sign in to comment.