Deleting a User

Sometimes users wish to remove themselves from your application and you might want to permanently delete their accounts.

The following sample shows how you can delete a user:

  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Delete the user.
    user.delete().then(
      function(theUser) {
        // Do something.
      }
    ).catch(
      function(error) {
        // Handle the error.
        var theUser = error.target;
        var errorString = error.message;
      }
    );
  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Delete the user.
    user.delete({
      success: function(theUser) {
        // Do something.
      },
      failure: function(theUser, errorString) {
        // Handle the error.
      }
    });

When a user is deleted, all data that belong to this user (i.e. buckets, KiiObjects, topics, and device installation) will be automatically deleted.

Note that a group and its data (i.e. buckets, KiiObjects, and topics) will not be deleted even if the group owner or the last group member is deleted.

The users can only delete themselves. A group owner cannot delete the group members. You can delete any user if you are the administrator.

If the user deletion succeeds, the login state is cancelled and the user is treated as an anonymous user.

You can also delete pseudo users by executing the method while they are logged in with their access tokens.