methods.js 1.53 KB
// import { } from '/imports/collections/orgs/methods';
import _                                  from 'lodash';
import { Meteor }                         from 'meteor/meteor';
import { ValidatedMethod }                from 'meteor/mdg:validated-method';
import { SimpleSchema }                   from 'meteor/aldeed:simple-schema';
import { DDPRateLimiter }                 from 'meteor/ddp-rate-limiter';
import { Bert }                           from 'meteor/themeteorchef:bert';
import { Users }                          from '/imports/collections/users/index';
import { Orgs }                           from '/imports/collections/orgs/index';
// import { sendNotificationAPN }            from '/imports/server/push/methods';
export const orgMethod = new ValidatedMethod({
  name: 'org.method',

  validate: new SimpleSchema({
    itemId: { type: String },
  }).validator(),

  run({itemId}) {
    return {};
  },

});

export const checkExistingOrg = new ValidatedMethod({
  name: 'checkExistingOrg',
  validate: new SimpleSchema({
    slug: { type: String },
  }).validator(),

  run({slug}) {
    org = Orgs.findOne({slug:slug});
    return org;
  },
});

export const checkEmailInOrg = new ValidatedMethod({
  name: 'checkEmailInOrg',

  validate: new SimpleSchema({
    email: { type: String },
    orgId: { type: String },
  }).validator(),

  run({email, orgId}) {
    console.log(orgId);
    user = Users.findOne({"orgId":orgId, "emails.address":email});
    if(user){
      return {success:true}
    }else{
      return {success:false}
    }
  },
});