How to use the meteor/meteor.Meteor.users function in meteor

To help you get started, we’ve selected a few meteor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reactioncommerce / reaction / imports / plugins / core / accounts / server / methods / group / addUser.js View on Github external
function changeMarketplaceOwner({ userId, permissions }) {
  // give global marketplace role to new owner
  Roles.setUserRoles(userId, permissions, Roles.GLOBAL_GROUP);
  // remove global from previous owner
  Meteor.users.update({ _id: Reaction.getUserId() }, { $unset: { [`roles.${Roles.GLOBAL_GROUP}`]: "" } });
}
github DemocracyEarth / sovereign / lib / interpreter.js View on Github external
const _migrateAddress = (address, settings, timestamp) => {
  log(`[web3] Migrating address ${address}...`);
  const voter = Meteor.users.find({ username: address.toLowerCase() }).fetch();
  const template = _getUserObject(address, settings, timestamp);

  // add new voter
  if (voter.length === 0) {
    template.profile = Object.assign(template.profile, settings.profile);
    const voterId = Meteor.users.insert(template);
    log(`[web3] Inserted new user ${voterId}`);
  } else {
    log(`[web3] Updated user with new settings.. ${address.toLowerCase()}`);
    const newSettings = settings;
    let hasCollective = false;
    if (voter[0].profile && voter[0].profile.collectives && voter[0].profile.collectives.length > 0) {
      for (let k = 0; k < voter[0].profile.collectives.length; k += 1) {
        if (voter[0].profile.collectives[k] === voter[0].profile.collectives) {
          hasCollective = true;
          break;
github fede-rodes / pickupgames / imports / ui / pages / marker / marker-page.jsx View on Github external
const MarkerPageContainer = createContainer(({ markerId }) => {
  // Subscribe to both marker data + participant names
  const subs = Meteor.subscribe('Markers.publications.getMarkerForMarkerPage', markerId);
  const marker = Markers.collection.findOne({ _id: markerId });
  const markerReady = subs.ready();

  // Extend marker object
  if (markerReady && marker) {
    const { createdBy, participants } = marker;
    const author = Meteor.users.findOne({ _id: createdBy });
    _.extend(marker, {
      createdByName: author.profile.name,
      createdByAvatar: author.avatar,
      participants: participants.map((participant) => {
        const p = Meteor.users.findOne({ _id: participant.userId });
        return _.extend(participant, {
          userName: p.profile.name,
          userAvatar: p.avatar,
        });
      }),
    });
  }

  return {
    urlState: {
      markerId,
github apinf / platform / users / client / profile / profile.js View on Github external
usersCollection () {
    // Return reference to Meteor.users collection
    return Meteor.users;
  },
  userEmail () {
github erxes / erxes / imports / api / conversations / server / conversations.tests.js View on Github external
it('unstar', function() {
        const conversationIds = [Factory.create('conversation')._id];

        Meteor.users.update(userId, {
          $set: { 'details.starredConversationIds': conversationIds },
        });

        unstar._execute({ userId }, { conversationIds });

        assert.equal(Meteor.users.findOne(userId).details.starredConversationIds.length, 0);
      });
    });
github ACGN-stock / acgn-stock / dev-utils / createSeedData.js View on Github external
module.exports.createSeedData = function({ reset } = {}) {
    console.log('createSeedData');

    if (reset) {
      console.log('reset database...');
      resetDatabase();
    }

    console.log('create users...');
    pttUserFactory.buildList(100).forEach((u) => {
      Accounts.createUser(u);
    });

    console.log('make user1 be admin...');
    Meteor.users.update({ username: 'user1' }, { $set: { 'profile.roles': 'superAdmin' } });

    console.log('create companies...');
    companyFactory.buildList(100).forEach((c) => {
      dbCompanies.insert(c);
    });

    console.log('make user1 be the manager of all companies...');
    setManagerOfAllCompanies(Meteor.users.find({ username: 'user1' }).fetch()[0]._id);

    console.log('randomly allocate stocks...');
    randomlyAllocateStocks();

    console.log('add companies to archive...');
    const companyArchiveBulk = dbCompanyArchive.rawCollection().initializeUnorderedBulkOp();
    dbCompanies
      .find({ isSeal: false })
github sozialhelden / accessibility-cloud / both / api / source-access-requests / server / invitations / request-access-to-source.js View on Github external
function sendAccessRequestEmailTo({
  requesterId,
  organizationId,
  approverId,
  source,
  message,
}) {
  const approver = Meteor.users.findOne(approverId);
  const requester = Meteor.users.findOne(requesterId);

  const requesterOrganization = Organizations.findOne(organizationId);
  const approverOrganization = Organizations.findOne(source.organizationId);

  const approverEmailAddress = approver.emails[0].address;
  const requesterEmailAddress = requester.emails[0].address;

  const requestId = SourceAccessRequests.insert({
    organizationId,
    sourceId: source._id,
    requesterId,
    message,
  });

  const selector = { _id: requestId };
github DemocracyEarth / sovereign / imports / startup / client / functions.js View on Github external
title = `navbar-${params}`;
    } else {
      const contractTitle = Contracts.findOne({ keyword: params }).title;
      if (Meteor.Device.isPhone()) {
        return TAPi18n.__('proposal');
      }
      return `${TAPi18n.__('proposal')} <strong><em>${contractTitle}</em></strong>`;
    }
  } else {
    for (const key in params) {
      if (title.length !== 0) { title += '-'; }
      switch (key) {
        case 'tag':
          return `<strong><em>${Tags.findOne({ keyword: params[key] }).text}</em></strong>${TAPi18n.__('proposals')}`;
        case 'username': {
          const identity = Meteor.users.findOne({ username: params[key] });
          if (identity) {
            const fullname = showFullName(identity.profile.firstName, identity.profile.lastName, identity.username);
            return `${fullname}`;
          }
          return `${TAPi18n.__('peer')} ${TAPi18n.__('proposals')}`;
        }
        case 'hash':
        case 'query':
          break;
        default:
          if (key !== 'peer') {
            title += `${key}-${params[key]}`;
          } else {
            title += key;
          }
      }
github signmeup / signmeup / imports / api / tickets / helpers.js View on Github external
students() {
    return Meteor.users.find({
      _id: { $in: this.studentIds }
    });
  },
github ACGN-stock / acgn-stock / server / methods / accuse / banUser.js View on Github external
const targetUser = Meteor.users.findByIdOrThrow(userId, { fields: { 'profile.ban': 1 } });
  const oldBanList = targetUser.profile.ban || [];

  const isAlreadyBanned = oldBanList.includes(banType);
  const shouldBan = ! isAlreadyBanned;

  if (violationCaseId) {
    dbViolationCases.findByIdOrThrow(violationCaseId, { fields: { _id: 1 } });
  }

  if (shouldBan) {
    Meteor.users.update(userId, { $addToSet: { 'profile.ban': banType } });
  }
  else {
    Meteor.users.update(userId, { $pull: { 'profile.ban': banType } });
  }

  const logTypeMap = shouldBan ? {
    accuse: '禁止舉報',
    deal:  '禁止下單',
    chat:  '禁止聊天',
    advertise:  '禁止廣告',
    editUserAbout: '禁止簡介',
    manager:  '禁任經理'
  } : {
    accuse: '解除舉報',
    deal: '解除下單',
    chat: '解除聊天',
    advertise: '解除廣告',
    editUserAbout: '解除簡介',
    manager: '解除禁任'