我在我的Meteor应用程序中使用useraccounts包。我希望管理员能够添加一个新的用户(并禁止通过前端注册)。因此,根据meteor-collection2的建议,我添加了一个带有SimpleSchema的集合。我还使用AutoForm创建了一个“添加用户”页面。
<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数据库中的用户设置默认密码。如何添加字段,以便管理员可以为该用户设置默认密码(用户稍后可以更改该密码)。
发布于 2015-10-09 03:24:29
为什么不只使用forbidClientAccountCreation和sendEnrollmentEmail
Accounts.config({
forbidClientAccountCreation: true
});
Meteor.methods({
'inviteUser': function (doc) {
check(doc, YourForm);
let userId = Accounts.createUser(doc);
Accounts.sendEnrollmentEmail(userId);
}
});https://stackoverflow.com/questions/33018155
复制相似问题