首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Meteor用户:仅限管理员用户添加用户

Meteor用户:仅限管理员用户添加用户
EN

Stack Overflow用户
提问于 2015-10-08 22:06:27
回答 1查看 200关注 0票数 0

我在我的Meteor应用程序中使用useraccounts包。我希望管理员能够添加一个新的用户(并禁止通过前端注册)。因此,根据meteor-collection2的建议,我添加了一个带有SimpleSchema的集合。我还使用AutoForm创建了一个“添加用户”页面。

代码语言:javascript
复制
<template name="addCustomerProfile">
  <div class="container">
    <h1>Edit document</h1>
    {{#if isReady 'updateCustomerProfile'}}
       {{#autoForm collection="Users" id="userForm" type="insert" }}
        <fieldset>
          {{> afQuickField name='emails.0.address'}}
          {{> afQuickField name='emails.0.verified'}}
          {{> afQuickField name='services.password'}}
          {{> afQuickField name='username'}}
          {{> afQuickField name='profile.firstName'}}
        </fieldset>
        <button type="submit" class="btn btn-primary">Add User</button>
      {{/autoForm}}
    {{else}}
      Nothing
    {{/if}}
   </div>
</template>

只要'services.password‘没有添加到表单中,我就可以添加用户,但显然在这种情况下,没有为Mongo数据库中的用户设置默认密码。如何添加字段,以便管理员可以为该用户设置默认密码(用户稍后可以更改该密码)。

EN

回答 1

Stack Overflow用户

发布于 2015-10-09 03:24:29

为什么不只使用forbidClientAccountCreationsendEnrollmentEmail

代码语言:javascript
复制
Accounts.config({
  forbidClientAccountCreation: true
});

Meteor.methods({
  'inviteUser': function (doc) {
    check(doc, YourForm);
    let userId = Accounts.createUser(doc);
    Accounts.sendEnrollmentEmail(userId);
  }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33018155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档