How to get role from user data on login

I was facing the same issue. I could solve it by extending the auth controller of the users-permissions plugin. strapi/auth.js at master · strapi/strapi · GitHub

You need to copy the whole callback function to /src/extensions/users-permissions/strapi-server.js and change line 59 to include your fields you want to populate:

const user = await strapi.query('plugin::users-permissions.user').findOne({ where: query, populate: ["role", "profile_picture"]});
1 Like