Resetting the User Password
A user can reset their password if they forget it.
The user can execute the password reset without logging in. Once the password is reset, the user access token obtained by logging in with the old password will be invalided. The user needs to relogin with the new password.
New password after reset
A new password will become valid after resetting the old password. The new password is determined by one of the following ways:
- Auto-generate by Kii Cloud (Default)
- Manually set by the user
You can configure the new password generation method on the developer portal. See Configuring the generation of a new password.
Resetting the password
A user can use either email or SMS when resetting their password. For SMS, you can set either a URL link or PIN code for resetting the password.
Resetting by email
Execute the resetPassword
method with the ID of the target user set in the first argument and KiiUser.NotificationMethod.EMAIL
set in the second argument. We are using the verified email address for specifying the target user in the sample code below; you can also use the user ID and the verified phone number.
When you execute the method, the user will receive an email with the URL link for resetting their password. The user's email address must be verified beforehand; you cannot use this method if the email address is unverified.
You can customize the content of the email on the developer portal. See Customizing Email/SMS Templates for the details.
The action that will take place when the user clicks the URL link depends on the configuration made on the developer portal.
Auto-generate by Kii Cloud: The password will be reset, and the auto-generated password will be notified to the user via email.
Manually set by the user: The user will be directed to the web page for entering a new password. When the user enters a new password, the password will be reset, and the specified new password becomes valid.
Resetting by SMS with a URL link
Execute the resetPassword
method with the ID of the target user set in the first argument and KiiUser.NotificationMethod.SMS
set in the second argument. We are using the verified phone number for specifying the target user in the sample code below; you can also use the user ID and the verified email address.
When you execute the method, the user will receive an SMS with the URL link for resetting their password. The user's phone number must be verified beforehand; you cannot use this method if the phone number is unverified.
You can customize the content of the SMS message on the developer portal. See Customizing Email/SMS Templates for the details.
The action that will take place when the user clicks the URL link depends on the configuration made on the developer portal.
Auto-generate by Kii Cloud: The password will be reset, and the auto-generated password will be notified to the user via SMS.
Manually set by the user: The user will be directed to the web page for entering a new password. When the user enters a new password, the password will be reset, and the specified new password becomes valid.
Resetting by SMS with a PIN code
Execute the resetPassword
method with the ID of the target user set in the first argument and KiiUser.NotificationMethod.SMS_PIN
set in the second argument. We are using the verified phone number for specifying the target user in the sample code below; you can also use the user ID and the verified email address.
When you execute the method, the user will receive an SMS with the PIN code for resetting their password. The user's phone number must be verified beforehand; you cannot use this method if the phone number is unverified.
Next, execute the completeResetPassword
method with the ID of the target user set in the first argument and the obtained PIN code set in the second argument.
How the completeResetPassword
method is to be executed and what kind of action will take place after executing the method depend on the configuration made on the developer portal.
Auto-generate by Kii Cloud: Specify a null in the third argument (If the argument is not null, it will be ignored). When the method is executed successfully, the password will be reset, and the auto-generated password will be notified to the user via SMS.
Manually set by the user: Specify the new password in the third argument. When the method is executed successfully, the password will be reset, and the specified password becomes valid.