PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

[FIXED] How to assign ‘author’ role to User in strapi.io?

 October 19, 2022     admin, frontend, mongodb, node.js, strapi     No comments   

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:

  1. Limit the set of APIs this role can access
  2. Define whether the route will be public or private to this role
  3. 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 Token is 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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing