Reputation: 222
I'm working on an application where only the admin should be able to create users for the system; meaning the user is restricted from creating an account but can login if login credentials were made for him/her.
I'm thinking about using houston:admin
to manually create users, but how can I restrict users from creating an account using accounts-ui
?
Should I use different packages to achieve this altogether?
Upvotes: 1
Views: 144
Reputation: 16488
You have several ways to prevent users from creating accounts:
throwing an error in the Accounts.onCreateUser() callback (server only):
Accounts.onCreateUser(function(options, user) {
if (/* some logic to figure out if current user is an admin */) {
return user;
}
throw new Meteor.Error("user creation disabled.");
});
This will prevent the account from being created if the current user is not an admin.
configuring Accounts
to forbid account creation (both client and server):
Accounts.config({
forbidClientAccountCreation: true
});
which rejects calls to createUser()
from the client (but will not prevent user creation using oAuth services).
A combination of both is a likely course of action. Take a look at the linked documentation for more details.
Upvotes: 2