Issue
In the user table when I am trying to assign a role to a user, it is showing public and authenticated options only. How to select ‘author’/‘editor’ or any other to the user through the admin panel and also through API?
Solution
First of all, you need to understand that the Editor, Author & Super Admin are roles for admin panel users only. So basically, it will only control/limit what the user can do after logging in into the admin panel (http://localhost:1337/admin). Additionally, these roles can only be assigned to the admin panel users which can be created by visiting the following module:
http://localhost:1337/admin/settings/users.
Now coming to your question, as to why we can't assign Editor/Author to users in the users collection, it's because the roles assigned to these users are in a separate module:
http://localhost:1337/admin/settings/users-permissions/roles
The roles created in this module are basically assigned to API consumers. So you could create roles of your own choice in this module and then:
- Limit the set of
APIs this role can access - Define whether the route will be
publicorprivateto this role - Set
rate limiting
Once you create the roles of your choice in this module, then you can go to users collection module.
http://localhost:1337/admin/plugins/content-manager/collectionType/plugins::users-permissions.user?page=1&pageSize=10&_sort=username:ASC
You could then create users (API consumers/users) who will have their own set of credentials (email & password) which can then be used for acquiring the bearer token.
So, to sum up, just create the roles you want to assign to users in this module and then use the user with that role for acquiring bearer token, following which you can call the APIs with that token. Simple!
P.S:
Bearer Tokenis used on the headers for accessing private routes enabled for that particular user role.
Answered By - Salvino D'sa Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.