Resetting the User Password

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 resetPasswordWithNotificationMethod method with the ID of the target user set in the first argument and "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.

  • // Send an email including a link for password reset.
    KiiUser.resetPasswordWithNotificationMethod("user_123456@example.com", "EMAIL").then(
      function() {
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var errorString = error.message;
      }
    );
  • // Send an email including a link for password reset.
    KiiUser.resetPasswordWithNotificationMethod("user_123456@example.com", "EMAIL", {
      success: function() {
        // Do something.
      },
      failure: function(errorString) {
        // Handle the error.
      }
    });

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.

Execute the resetPasswordWithNotificationMethod method with the ID of the target user set in the first argument and "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.

  • // Send an SMS message including a link for password reset.
    KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS").then(
      function() {
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var errorString = error.message;
      }
    );
  • // Send an SMS message including a link for password reset.
    KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS", {
      success: function() {
        // Do something.
      },
      failure: function(errorString) {
        // Handle the error.
      }
    });

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 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 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 resetPasswordWithNotificationMethod method with the ID of the target user set in the first argument and "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.

  • // Send an SMS message including a PIN code for password reset.
    KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS_PIN").then(
      function() {
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var errorString = error.message;
      }
    );
  • // Send an SMS message including a PIN code for password reset.
    KiiUser.resetPasswordWithNotificationMethod("+819001234567", "SMS_PIN", {
      success: function() {
        // Do something.
      },
      failure: function(errorString) {
        // Handle the error.
      }
    });

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.

  • // Reset the password.
    KiiUser.completeResetPassword("+819001234567", "123456", "new_password_00").then(
      function() {
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var errorString = error.message;
      }
    );
  • // Reset the password.
    KiiUser.completeResetPassword("+819001234567", "123456", "new_password_00", {
      success: function() {
        // Do something.
      },
      failure: function(errorString) {
        // Handle the error.
      }
    });

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.