Enable User¶
Description¶
This operation changes the user status to ENABLED
.
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.
Method¶
Blocking API
public void Backendless.UserService.enableUser( userObjectId );
Non-Blocking API
public void Backendless.UserService.enableUser( userObjectId, AsyncCallback<Void> responder );
where
Argument | Description |
---|---|
userObjectId |
Unique identifier of the user account to be enabled. String value or number. Refer to the Data Import topic to learn more about objectId value as the number. |
responder |
A callback object which will receive a callback when the method successfully changes the user status. Applies to the non-blocking method only. |
Return Value¶
None.
Example¶
The example below enables the user associated with the following objectId: "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD"
.
Blocking API
String userObjectId = "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD";
Backendless.UserService.enableUser( userObjectId );
Non-Blocking API
String userObjectId = "4D584E4D-05A3-4AC4-90C7-B80D1584E7AD";
Backendless.UserService.enableUser( userObjectId, new AsyncCallback<Void>()
{
@Override
public void handleResponse( Void unused )
{
// result handling logic
}
@Override
public void handleFault( BackendlessFault backendlessFault )
{
// error handling logic
}
} );
Codeless Reference¶
where:
Argument | Description |
---|---|
id |
objectId/unique identifier of a user account to be enabled. |
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 DISABLED
.
The example below enables 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 ENABLED
.