简体   繁体   中英

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. 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

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.

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.

如果您使用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

Let me know if this works or not. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM