Reputation: 1095
I am using alanning:roles and have put my users in admin groups successfully in my server - main file. However now I'm trying to add Meteor.users.allow() to my admin in order to allow them to delete other users. I'm having trouble finding an example of the right location within my code to put this. Do I put it in the server main under startup? or in a separate users collection (I'm using React)?
I think this is illustrating a blindspot in my understanding of meteor or react so if you're feeling instructive, please help me out :) Thanks!
Upvotes: 0
Views: 55
Reputation: 1579
If you are working with Meteor more recent than 1.3.0, you can place your hooks/allows/methods files anywhere under a server
subdirectory, as long as you import
(as in the ES6 module import) them. It's helpful to have them separated logically.
Here is a sample directory structure we're using in our project:
public/ (static files, assets)
settings/ (to be loaded as command-line args for different environments)
test/
imports/
client/
startup/
components/
views/
server/
startup/
allows/
hooks/
methods/
publications/
both/
utils/
collections/ (collections are here, because they're shared)
Now, to be honest, this is an older project, so React was not considered here, but this could still be helpful for you when you're organizing your imports. Obviously, you're going to need a couple of entry files for your client and server that import all of the necessary dependencies.
From then on, for example, in your imports/server/allows/<collection_name>.js
file, you place your allows like:
import { SomeCollection } from '/imports/both/collections/someCollection.js';
SomeCollection.allow({
insert: function () {
return true;
},
update: function () {
return true;
},
remove: function () {
return true;
}
});
I prefer using absolute file path imports in Meteor projects, since there the root path resolves to the root of your project. Makes them easier to copy-paste.
Hope that helps.
Upvotes: 1