Skip to content

Commit

Permalink
Fix: add getOrg to local and passport.local (#404)
Browse files Browse the repository at this point in the history
* add getOrg to local and passport.local

The ClusterSubscription client calls subscriptionsByTag which calls getOrg.  Currently only the default auth model has getOrg implemented so this would cause local and passport.local users of ClusterSubscription to get errors

* ClusterSubscription clients won't have models.User entries
  • Loading branch information
dalehille authored Jun 11, 2020
1 parent 531fd8e commit d378cba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/apollo/models/user.local.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ UserLocalSchema.statics.isAuthorized = async function(me, orgId, action, type, a
return false;
};

UserLocalSchema.statics.getOrg = async function(models, me) {
let org;
if (AUTH_MODEL === AUTH_MODELS.LOCAL) {
org = await models.Organization.findOne({ orgKeys: me.orgKey }).lean();
}
return org;
};

UserLocalSchema.statics.getOrgs = async function(context) {
const results = [];
const { models, me } = context;
Expand Down
8 changes: 8 additions & 0 deletions app/apollo/models/user.passport.local.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ UserPassportLocalSchema.statics.isAuthorized = async function(me, orgId, action,
return false;
};

UserPassportLocalSchema.statics.getOrg = async function(models, me) {
let org;
if (AUTH_MODEL === AUTH_MODELS.PASSPORT_LOCAL) {
org = await models.Organization.findOne({ orgKeys: me.orgKey }).lean();
}
return org;
};

UserPassportLocalSchema.statics.getOrgs = async function(context) {
const results = [];
const { models, me } = context;
Expand Down

0 comments on commit d378cba

Please sign in to comment.