Setting user role based on role sent from frontend

System Information
  • Strapi Version: 4.8.2
  • Operating System: 11
  • Database: pg
  • Node Version: v18.14.0
  • NPM Version: 9.6.0
  • Yarn Version:

i have set two roles in settings and i have the default user collection type and i want to set the role based on the data i get sent through front end.

example i have two roles role a and role b for user i want to set the role a for certain users and role b for certain users, their roles will be sent through the front end, flutter, and for that i was trying to set the role in postman but was unable to do so then in the code which is generated by strapi i tried to edit but then i would get the error:

Cannot write file ‘c:/Users/DELL/Desktop/strapi/learn-strapi/src/admin/app.example.js’ because it would overwrite input file.ts
Cannot write file ‘c:/Users/DELL/Desktop/strapi/learn-strapi/src/admin/app.example.js’ because it would overwrite input file.ts

can anyone please help with this ?


i just made an interesting discovery you can set the role if you are using graphql but if you send it through postman in body for api it does not set the role it sets it to default

Hi there, how did you set the role?