-
Notifications
You must be signed in to change notification settings - Fork 4
updateRoleApi
The Update User Role API endpoint allows authorized users with owner privileges to modify the role of another user in the system. This endpoint necessitates authentication through a JSON Web Token (JWT) and enables the promotion or demotion of users by specifying their email and the new role (either "user" or "admin"). It allows for the promotion and demotion of users based on the specified role, facilitating efficient management of user roles within the system.
-
URL:
https://industrialiot.onrender.com/api/updaterole
-
Method:
PUT
-
Headers:
-
Authorization:
Bearer <ACCESS_TOKEN>
-
Content-Type:
application/json
-
Authorization:
- Body Parameters:
Parameter | Type | Description |
---|---|---|
email |
String | User's email (required) |
role |
String | New role (user/admin) (required) |
-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "User's role has been updated successfully" }
- Description: Indicates that the user's role has been updated successfully.
-
Error Responses:
-
Status Code: 400 Bad Request
-
Response Body:
{ "Error": "Invalid Email" }
- Description: Indicates an invalid or unrecognized email provided.
-
Response Body:
-
Status Code: 400 Bad Request
-
Response Body:
{ "Error": "User has not verified their email" }
- Description: Indicates that the user's email has not been verified.
-
Response Body:
-
Status Code: 400 Bad Request
-
Response Body:
{ "Error": "Unknown role" }
- Description: Indicates an unrecognized or unsupported role provided.
-
Response Body:
-
Status Code: 304 Not Modified
-
Response Body:
{ "Msg": "Role not updated but same" }
- Description: Indicates that the user's role remains the same as the updated role.
-
Response Body:
-
-
Request Method:
PUT
-
Endpoint URL:
https://industrialiot.onrender.com/api/updaterole
-
Header:
Authorization: Bearer <JWT> Content-Type: application/json
-
Request Body:
{ "email": "user@example.com", "role": "<NEW_ROLE>" }
Note: The
role
field in the request body should only contain either"admin"
or"user"
to represent the desired role, facilitating either the promotion or demotion of users within the system.