Populate users-permissions to get user role

System Information
  • Strapi Version: 4.0.7

Hello !

How to populate “role” field at authentification of a user with local users-permissions ?
I try to show frontend element conditionaly depends of user role.

Thanks you very much !

1 Like

Very much interested in an answer to that !

Only way I could get the roles was to call API/users/me after login.

### Get permissions
GET {{HOST}}/api/users/me?populate=role
Content-Type: application/json
Authorization: Bearer {{jwt}}

You must grant access to the following ( otherwise it fails to include the role :frowning: )

      "action": "plugin::users-permissions.role.find"
      "action": "plugin::users-permissions.role.findOne"
      "action": "plugin::users-permissions.user.me"

I am using next-auth so I added roles[] to my JWT/SESSION callbacks & types