This can be broken down into two parts:
1) How to specify an account as an administrator?
This is what I have going on right now and it doesn't work.
Meteor.startup(function () {
if (Meteor.users.find().count() === 0) {
console.log("Adding fake data");
Accounts.createUser({username:"admin", email:"[email protected]", password:"1234", admin: true, profile:{name:"Administrator"}});
}
The "admin" property of the user doesn't work. I'm not sure putting it in the profile is the right thing to do... Any suggestions here?
2) How can I restrict user creation to only administrators?
This is what I have going and it also doesn't work
Meteor.users.allow({
insert: function(userId, doc) {
// only admin and create
return (userId && Meteor.users(userId).admin);
},
Check out the authorization Atmosphere plugin. It handles role-based authorization and has an example of restricting new user creation to authorized users.