Reputation: 277
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 [email protected]
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.
Upvotes: 1
Views: 88
Reputation: 407
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!
Upvotes: 1
Reputation: 7777
If you create the user in a Meteor method (ie on the server, not the client), it will create the user in the backend, and not change the login status of the current user.
Upvotes: 2