Closed braytonstafford closed 6 years ago
Hey sorry I never answered. The reason is that the user object is structured like this:
{ [strategyname]: { [key]: value } }
so to set the role correctly with mongodb the query should be
db.users.update(
{
_id: ObjectId("5ba46cac9a370b50b10ae4f4")
},
{
$set: {
roles: {roles:["admin"]}
}
}
);
I was hoping to be able to access the currently authenticated user's roles via this.props.user inside a react component wrapped with withUser HOC.
I've followed the example in the docs on implementing user roles.
I manually added the admin role to my user and verified in mongodb that roles on the user is an array.
Then inside the withUser wrapped component if I console.log('user ', this.props.user.roles) it prints
I was expecting roles to be an array of strings?
Sidenote: After manually updating my role to admin I was able to use oothClient to successfully update a different user's roles as the docs' explain.