Ejemplo n.º 1
0
Meteor.publish('oauthApps', function() {
	if (!this.userId) {
		return this.ready();
	}
	if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) {
		this.error(Meteor.Error('error-not-allowed', 'Not allowed', { publish: 'oauthApps' }));
	}
	return RocketChat.models.OAuthApps.find();
});
Ejemplo n.º 2
0
      instance.timeframe, dateRange, periodType, (error, result) => {
        if (error) {
          // Create & display error message
          const message = `Fetching ${periodType} summary statistics fails. ${error.message}`;
          sAlert.error(message);
          throw Meteor.Error(error.message);
        }

        if (periodType === 'current') {
          // Mark as Ready
          instance.summaryIsReady.set(true);
          // Store summary statics for current period
          instance.currentPeriod.set(result);
        } else {
          // Store summary statistics for previous period
          instance.previousPeriod.set(result);
        }
      });
Ejemplo n.º 3
0
    // Call both check and validate because by calling `clean`, the audit pkg
    // thinks that we haven't checked paymentMethod arg
    check(paymentMethod, Object);
    PaymentMethodArgument.validate(PaymentMethodArgument.clean(paymentMethod));

    const result = {
      saved: false,
      error: "Reaction does not yet support direct refund processing from Authorize.net. " +
      "Please visit their web portal to perform this action. https://account.authorize.net/"
    };

    return result;
  },
  "authnet/refund/list"(...args) {
    check(args, [Match.Any]);
    Meteor.Error("not-implemented", "Authorize.net does not yet support retrieving a list of refunds.");
    return [];
  }
});

function getAuthnetService(accountOptions) {
  const {
    login,
    tran_key,
    mode
  } = accountOptions;

  return new AuthNetAPI({
    API_LOGIN_ID: login,
    TRANSACTION_KEY: tran_key,
    testMode: !mode
Ejemplo n.º 4
0
		if(!Meteor.userId()){
			throw new Meteor.Error('not-authorized');
		}

		Tasks.insert({
			text,
			createdAt:new Date(),
			owner:Meteor.userId(),
			username:Meteor.user().username,
		});
	},
	'tasks.remove'(taskId){
		check(taskId,String);
		const task=Tasks.findOne(taskId);
		if(task.private&&task.owner!==Meteor.userId()){
			throw Meteor.Error('not-authorized')
		}
		Tasks.remove(taskId);
	},
	'tasks.setChecked'(taskId,setChecked){
		check(taskId,String);
		check(setChecked,Boolean);
		const task=Tasks.findOne(taskId);
		if(task.private&&task.owner!==Meteor.userId()){
			throw Meteor.Error('not-authorized');
		}
		Tasks.update(taskId,{
			$set:{checked:setChecked}
		});

	},
Ejemplo n.º 5
0
    const messageId = Messages.insert(message);
    Chats.update(message.chatId, { $set: { lastMessage: message } });

    return messageId;
  },
  updateName(name) {
    if (!this.userId) {
      throw new Meteor.Error('not-logged-in',
        'Must be logged in to update his name.');
    }

    check(name, String);

    if (name.length === 0) {
      throw Meteor.Error('name-required', 'Must provide a user name');
    }

    return Meteor.users.update(this.userId, { $set: { 'profile.name': name } });
  },
  newChat(otherId) {
    if (!this.userId) {
      throw new Meteor.Error('not-logged-in',
        'Must be logged to create a chat.');
    }

    check(otherId, String);
    const otherUser = Meteor.users.findOne(otherId);

    if (!otherUser) {
      throw new Meteor.Error('user-not-exists',