Reputation: 23
Recently I began to use MeanJs, it's pretty amazing but I don't understand some stuff. I need to create a simple user management for my backend.
From official blog they say:
New usability features: Added roles to the User model - the defaults are ‘user’ and ‘admin’, you can add and remove them as needed.
After a search I found some examples but all of these about meanio, not meanjs, there are a package MEAN-ADMIN in meanio that does it for us but in meanjs I not found.
Someone know the best way to implement a user management? some example?
Thanks guys.
Upvotes: 2
Views: 3321
Reputation: 1409
The meanjs generator comes with some basic user roles built in. The roles is an array on the user model.
roles: {
type: [{
type: String,
enum: ['user', 'admin']
}],
default: ['user']
},
To add a user with the role admin just attach it to the user object before saving.
user.roles = ['admin'];
If you want to use roles apart from admin and user you need to add then to the type enum.
Upvotes: 5