Password Verification¶
Description¶
When a user needs to change their password in your application, you may need to verify their existing password for security reasons. Since Backendless stores passwords in the encrypted format and never returns the password value, you need to use the API call documented below to implement password verification. The API checks the provided password value against the one stored in the database. User must be logged - Backendless verifies provided value for the currently logged in user.
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¶
Backendless.UserService.verifyPassword(currentPassword): Promise<boolean>;
where:
Argument | Description |
---|---|
currentPassword |
Value to check against the password stored in the database. String value. |
Return Value¶
true
if the password is correct, otherwise false
.
Example¶
The example below verifies the password "wonderland"
against the password stored in the Backendless database.
const onSuccess = isPasswordVerified => console.log('Is password verified:', isPasswordVerified)
Backendless.UserService.verifyPassword("wonderland")
.then(onSuccess)
Codeless Reference¶
Returns true
if the password is correct, otherwise false
.
Consider the following record in the Users
data table:
The example below logs in as "alice@wonderland.com"
to obtain the user token which is required for this operation. Then it verifies the user password and returns true
since passwords match.