changePassword
This method is very similar to the forgot password feature. But unlike forgot password, here it is important for a user to be logged into his account first. To ensure the security of a user account, we send a verification code to the phone number associated with user account and return you a confirmation method.
Change password function accepts the following arguments
Name | Type | Description |
---|---|---|
password | string | should be minimum six character long |
This method returns the following code in form of promise
PHONE-CODE-SENT
verification code sent to phone number and you use the confirmation method returned in the response of promise to verify the user.
DATA-INVALID
data format is invalid
AUTH-UNAUTHORIZED
user is required to be logged in
PHONE-CODE-SENDING-FAILED
failed to send code to phone number
confirm(code)
After submitting change password request, we send a verification code to the phone number associated with the user's accounts. As a result, we also return you a confirmation function, so that you could proceed with the change password operation after prompting the user about the verification code.
This function receives a single argument as illustrated below
Parameters
Name | Type | Description |
---|---|---|
code | string | six digit long numeric code |
Upon execution, this method returns the following code in the form of promise
AUTH-PROFILE-UPDATED
password has been updated
PHONE-CODE-INVALID
verification code is invalid
PHONE-CODE-VERIFICATION-FAILED
failed to verify the verification code
AUTH-PROFILE-UPDATE-FAILED
failed to update the profile
Use of changePassword method has been illustrated in the example below
// Variable to hold the confirmChangePassword
// method so that it could be used afterwards
var confirm = null;
// Get user data from the inputs and
// Submit request to the server
auth.changePassword(password).then((res) => {
// Got the response
// So checkout the response code
switch(res.code) {
case "PHONE-CODE-SENT":
// Verification code has been sent
confirm = res.confirm;
}
})
// After getting response from change password request
// Prompt the user about the verification code
// and submit it to server with the confirm method
confirm(code).then((res) => {
// Got the response
switch(res.code) {
case "AUTH-PROFILE-UPDATED":
// Password has been updated
}
});