[英]Meteor.js / React.js App - how to add another user while you're logged in
How do I add another user while I'm logged in in a Meteor application. 我在Meteor应用程序中登录时如何添加其他用户。 I want to give to an admin an ability to create users himself without logging out.
我想给管理员一个能够自己创建用户而无需注销的能力。
For login system I use accounts-password@1.3.2 对于登录系统,我使用accounts-password@1.3.2
If I use Accounts.createUser(user, function (e) { ... } then it logs out my admin and after a page refresh it logs in with a new user instead. 如果我使用Accounts.createUser(用户,函数(e){...},那么它会注销我的管理员,在页面刷新后,它会以新用户身份登录。
SOLVED: 解决了:
Thanks to below answers I created 感谢我创建的以下答案
Meteor.call('addingUser.insert', user);
on the front where user is an object of values and then 在用户是值的对象的前面然后
'addEmployee.insert'(user) {
Accounts.createUser(user);
}
on the back end and a user was added successfully with an appropriately generated bcrypt password. 在后端,用适当生成的bcrypt密码成功添加了用户。
如果您使用Meteor方法(即在服务器而不是客户端)创建用户,它将在后端创建用户,而不是更改当前用户的登录状态。
Create a method that handles user creation (you could use accounts-password for this) in the server. 在服务器中创建一个处理用户创建的方法(您可以使用帐户密码)。 Call that method in the client.
在客户端中调用该方法。
for more info about accounts-password refer to this: http://docs.meteor.com/api/passwords.html#Accounts-createUser 有关帐户密码的更多信息,请参阅: http : //docs.meteor.com/api/passwords.html#Accounts-createUser
Let me know if this works or not. 让我知道这是否有效。 Thanks!
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.