Skip to content

Commit

Permalink
Merge pull request #322 from razee-io/register_org_bug
Browse files Browse the repository at this point in the history
Fix: use the localUser function in orgsForUser check
  • Loading branch information
dalehille committed Jun 17, 2020
2 parents a5eaf8b + cfb01a7 commit fc0fe41
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 fc0fe41

Please sign in to comment.