I'm try register an user and i would like to know how can i set role as Administrator. I tried
user: {
username: "elialber",
email: "[email protected]",
password: "123456789",
role: ???
}
I'm using Angular5 and just api strapi
step 1: Go to node_modules/strapi-plugin-users-permissions/controllers/Auth.js step 2: Go to on line 457(in my code) step 3: Comment params.role=role.id; like (//params.role = role.id;)
and now you can pass role id like 1 or 2 or 3 as follow
{
"blocked":false,
"confirmed":true,
"username":"aziz",
"email":"[email protected]",
"password":"musa01010",
"role": 2
}
and now I receive a response like:
{
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzQsImlhdCI6MTYwMjUzMzk0MSwiZXhwIjoxNjA1MTI1OTQxfQ.xM2tmP8PUcwABiW9lmxkjkmcmdmckMB8wlQ1YsBOQI",
"user": {
"id": 34,
"username": "aziz",
"email": "[email protected]",
"provider": "local",
"confirmed": true,
"blocked": false,
"role": {
"id": 2,
"name": "Public",
"description": "Default role given to the unauthenticated user.",
"type": "public"
},
"created_at": "2020-10-12T20:19:01.285Z",
"updated_at": "2020-10-12T20:19:01.299Z"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With