Disable User¶
Description¶
This operation changes the user status to DISABLED
.
This functionality can be used only in CloudCode (Java, JS or Codeless), the reason for this restriction is that a malicious use of this API can easily compromise application's security. As a result, this API must be used from a controlled environment. It is important the REST API is used with the CloudCode API key.
Method¶
PUT
Endpoint URL¶
https://api.backendless.com/<application-id>/<CLOUDCODE-api-key>/users/<user-objectId>/status
where:
Argument | Description |
---|---|
<application-id> |
The ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console. |
<CLOUDCODE-api-key> |
CloudCode API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console. |
<user-objectId> |
A value of the "objectId" property/column for the user account to disable. |
Request Headers¶
Content-Type:application/json
where
Argument | Description |
---|---|
Content-Type |
Must be set to application/json . This header is mandatory. |
Request Body¶
{
"userStatus" : "ENABLED" | "DISABLED"]
}
Response Body¶
None.
Example¶
The example below disables the user associated with the following objectId: "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD"
.
curl --location --request PUT 'https://xxxx.backendless.app/api/users/4D584E4D-05A3-4AC4-90C7-B80D1584E7AD/status' \
--header 'Content-Type: application/json' \
--data-raw '{
"userStatus": "DISABLED"
}'
Codeless Reference¶
where:
Argument | Description |
---|---|
id |
objectId/unique identifier of a user account to be disabled. |
Important
This Codeless block is only available in CloudCode due to the security reasons. If this operation is exposed to users, then your application can be compromised.
This operation does not return a value.
Consider the following record in the Users
data table:
Note that the userStatus
column contains the current user status which is ENABLED
.
The example below disables the user "alice@yourmail.com"
associated with the objectId: "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD"
.
After the Codeless logic runs, the user status successfully changes to DISABLED
.