-
Notifications
You must be signed in to change notification settings - Fork 2k
How to implement user with "admin" role, which is able to edit another users? #515
Comments
You need a middleware that uses |
Yeah, I got it few minutes ago too :D Thanks! :) |
Hi, one query Thanks! |
Having > 1 role for an user can be achieved through direct MongoDB database manipulation, e.g. in the mongo shell. |
The solution is this: In users.server.controller.js
|
@marianoqueirel remember that then you'll also need a middleware to validate roles. Otherwise you might as well just leave all admin pages open... |
Ofcourse, in the route you can do this:
Or if you want, you could do this from the Angular. |
We are adding an admin module in the very near future for the specific purpose of adding additional roles to users: Can prolly close this issue |
yep, thanks @trainerbill |
Hello! Can someone please help me with a step by step tutorial about setting up an admin user on my meanjs app? Thank you! |
@bruna94 You can use the seed feature MONGO_SEED=true grunt The users and passwords will appear in the console |
im sorry i executed this in GitBash but the console of the page does not show anything... am i doing something wrong? |
What version of MEAN are you running? The seed feature was added within On Thu, Sep 24, 2015 at 12:15 PM, bruna94 [email protected] wrote:
|
@bruna94 Take this to the gitter chat so we don't revive this issue. |
@marianoqueirel |
The issue I think I am running into is when editing other users profiles the password gets changed due to the 'pre' hook on user save whenever you try and save the changed profile: UserSchema.pre('save', function(next) {
}); |
@ckapop What version of MEANJS are you seeing this behavior? Can you provide step-by-step instructions on how to reproduce? The password field should never be present in either the request, or response. If the password is updated, in a request other than the create profile, then this would indeed be a bug. However, I think we took care of any issues with this already. |
@mleanos How can I check to be sure? It is probably not as current as it should be. I have this method that was generated when the mean app was created using 'yo' which looks like the new password is in the request, correct? /**
|
Hi, I've got this in my
user.server.routes.js
Problem is with
app.param
, because methoduserByID
is returning logged in user, so when I click on delete, it will delete my account...If I changeapp.param
to find user from DB by userId, I'm getting authorization problems (403 forbidden) :( Could someone help me to solve this problem?Thank you very much!
If I neglect safety ...
Now I am able to delete users, but If I edit some user, it will change logged in user to the edited one :(
The text was updated successfully, but these errors were encountered: