Creating a "Manage Users" admin page, need to list users and their roles


#1

I use the Meteor Roles package to give users groups and roles. So far I’ve created some users and manually added them to groups/roles. Now I’m trying to build a “Manage Users” page for the admin to view all users and their groups/roles in a table, and be able to adjust them from that page with a drop down menu.

For example, something along the lines of this. That one is taken from a tutorial on The Meteor Chef, which can be found here. The tutorial is great, but I’m running into troubles as it uses flow router instead of iron router (which I use), as well as it doesn’t seem to take into account user groups. I also am only needing the list of users and ability to adjust their groups/roles, and not the invitations at this time.

What would be the best way for me to achieve this? It feels like a relatively simple thing to implement but I’ve gotten a little lost. I’m fairly new to Meteor and would greatly appreciate any code examples or anything at all.

Thanks!


#2

Take a look at the accounts-admin-ui-bootstrap-3 package. It’s a bit dated and geared towards bootstrap, but it works with Iron Router and should help serve as a reference app (if you can’t use it directly).


#3

Thanks for sharing! I’ve been trying to use it as a reference and make that work but unfortunately having no success so far, I seem to be having a lot of troubles because I am using groups for my users. I’ve tried looking for other projects to use as references that have a UI to manage users and assign them groups and permissions for those groups but can’t seem to find any.

I’ll continue to try and make it work and I’ll be sure to update my thread on here if I can find a way to make it happen.


#4

That package will let you mange users and roles, and assign users to roles. It won’t help you manage role permissions, but it should get you part way there. Did you get it running? Here are a few quick screenshots showing how it works.


#5

Thanks for the info/screenshots! I now have the package installed, but there are a couple of issues.

I have created several users for the site but for some reason the only one that appears in the manage users table is the account which I am signed into, none of the others are appearing.

I can see the roles listed when I click the “Manage Roles” button, although under “Roles” in the table it just says “[object Object]” I assume this is because I am using groups.

Here is a screenshot showing what it looks like:


#6

If you are certain that a user will only have one role within a group, then you can use the following markup in your html
{{roles.default_group.[0]}}

otherwise, you need to add a helper, such as
Template.users.helpers({ 'rolesAsString': function() { roles.default_group.toString(); } });


#7

Hi,
I have added the bootstrap and I am getting the admin dashboard . However There is no option to update role. that feature is not coming on my admin dashboard