當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Meteor.users.remove方法代碼示例

本文整理匯總了TypeScript中meteor/meteor.Meteor.users.remove方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meteor.users.remove方法的具體用法?TypeScript Meteor.users.remove怎麽用?TypeScript Meteor.users.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在meteor/meteor.Meteor.users的用法示例。


在下文中一共展示了Meteor.users.remove方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: addTestUser

function addTestUser(username:string, email:string, role:string) {
  let existsUser:any = Accounts.findUserByEmail(email) ? true : false;
  if (existsUser) {
    Meteor.users.remove({_id: existsUser._id});
  }
  const password = "1234";
  log.info("Created Username:" + username + ", email: " + email +", password:" + password + ", role:" + role );
  var user = Accounts.createUser({username: username, email: email, password: password});
  Roles.addUsersToRoles(user, [role]);
}
開發者ID:kokokenada,項目名稱:for-real-cards,代碼行數:10,代碼來源:user.model.ts

示例2: extend

Accounts.onCreateUser((options, user) => {
    let currentService, loginEmail;

    user.profile = extend({}, user.profile, options.profile);

    if (user.services) {
        currentService = first(keys(user.services));
        loginEmail = user.services[currentService].email;
    }

    const originalUser = Meteor.users.findOne({'verified_emails': loginEmail});

    if (!originalUser) {
        return user;
    }

    // remove old account
    try {
        Meteor.users.remove(originalUser._id);
    } catch (e) {
        throw new Meteor.Error(500, e.toString());
    }


    // add the services to the new account
    for (let service of REGISTERED_SERVICES) {
        if (originalUser.services[service]) {
            user.services[service] = originalUser.services[service];
        }
    }

    // update posts
    Posts.update({ author: originalUser._id }, { $set: { author: user._id }}, { multi: true });
    user.profile = extend({}, originalUser.profile, user.profile, options.profile);

    return user;
});
開發者ID:kucharskimaciej,項目名稱:bullet-journal,代碼行數:37,代碼來源:on_create_user.ts

示例3: if

Accounts.onCreateUser((options, user) => {
  // Grab the default profile object if it exists.
  const profile = (options.profile !== undefined) ? options.profile : user.profile;
  let service;
  let address;

  if (user.services) {
    for (const serviceName in user.services) {
      if (Object.hasOwnProperty.call(user.services, serviceName)) {
        service = user.services[serviceName];
        address = (service.email) ? service.email : false;
        if (!address) {
          const emails = (serviceName === 'password') ? user.emails : service.emails;
          for (let i = 0; i < emails.length; i++) {
            const email = emails[i];
            if (email.primary) {
              address = email.address;
            }
          }
        }

        if (service.username && !profile.name) {
          profile.name = service.username;
        }
        // Create or merge the profiles if needed.
        if (!user.profile && profile) {
          user.profile = profile;
        } else if (profile) {
          user.profile = Object.assign(profile, user.profile);
        }

        if (address) {
          const _emails = user.emails || [];
          _emails.push({ address });
          user.emails = _emails;
        } else {
          return user;
        }
      }
    }

    // BEWARE!!! Hackery below
    // See if any existing user has this email address, otherwise create new
    // From http://meteorpedia.com/read/Merging_OAuth_accounts
    const existingUser = Meteor.users.findOne({ 'emails.address': address });
    if (!existingUser) {
      return user;
    }

    // Precaution: these will exist from accounts-password if used
    if (!existingUser.services) {
      existingUser.services = {
        resume: {
          loginTokens: [],
        },
      };
    }
    if (!existingUser.services.resume) {
      existingUser.services.resume = {
        loginTokens: [],
      };
    }

    // Copy accross new service info
    existingUser.services[service] = user.services[service];
    if (user.services.resume) {
      if (user.services.resume.loginTokens) {
        existingUser.services.resume.loginTokens.push(
          user.services.resume.loginTokens[0]
        );
      }
    }

    // Create emails if needed.
    if (!existingUser.emails && user.emails) {
      existingUser.emails = user.emails;
    }

    // Create or merge the profiles if needed.
    if (!existingUser.profile && user.profile) {
      existingUser.profile = user.profile;
    } else if (user.profile) {
      existingUser.profile = Object.assign(user.profile, existingUser.profile);
    }

    // Even worse hackery
    Meteor.users.remove({ _id: existingUser._id }); // Remove the existing record
    return existingUser;              // Record is re-inserted
  }
  return user;
});
開發者ID:andyp22,項目名稱:my_resume,代碼行數:91,代碼來源:accounts.ts

示例4: function

//         console.log("selector" + selector)
//         console.dir(selector)
//                 console.dir(options)
//     console.log("searchString" + searchString)
//   return Meteor.users.find(selector , options);
// });


Meteor.methods({

    'users.insert'(user) {
        Meteor.users.insert(user);
    },
    'users.remove'(userId) {
        Meteor.users.remove(userId);
    },
    'users.update'(userId, action) {
        Meteor.users.update(userId, action);
    },
    'users.getUsers'() {
        console.log('on server, Meteor.users.find({}) called');
        return Meteor.users.find({}).fetch();
    },

});

Meteor.users.allow({
    insert: function () {
        return true;
    },
開發者ID:admirkb,項目名稱:ads,代碼行數:30,代碼來源:users.ts

示例5:

 options.users.forEach((user:any)=>{
   let r = Meteor.users.remove({_id: user});
   console.log(r);
 });
開發者ID:p3140,項目名稱:angular2-meteor-starter-kit,代碼行數:4,代碼來源:methods.ts

示例6:

Meteor.startup(() => {
  Posts.remove({});
  TimeLines.remove({});
  Meteor.users.remove({});
});
開發者ID:RizkiMufrizal,項目名稱:Socially-Angular2-Meteor,代碼行數:5,代碼來源:main.ts


注:本文中的meteor/meteor.Meteor.users.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。