lib/controllers/change-password.js
function resetPasswordWithRecoveryToken(client, recoveryTokenResource, newPassword, callback) {

  var userHref = '/users/' + recoveryTokenResource._embedded.user.id;

  client.getAccount(userHref, function (err, account) {

    if (err) {
      return callback(err);
    }

    var href = '/authn/recovery/answer';
    var body = {
      stateToken: recoveryTokenResource.stateToken,
      answer: account.profile.stormpathMigrationRecoveryAnswer
    };

    client.createResource(href, body, function (err, result) {

      if (err) {
        return callback(err);
      }

      var href = '/authn/credentials/reset_password';
      var body = {
        stateToken: result.stateToken,
        newPassword: newPassword
      };

      client.createResource(href, body, callback);

    });
  });
}
function resetPasswordWithRecoveryToken(client, recoveryTokenResource, newPassword, callback) {

  var userHref = '/users/' + recoveryTokenResource._embedded.user.id;

  client.getAccount(userHref, function (err, account) {

    if (err) {
      return callback(err);
    }

    var href = '/authn/recovery/answer';
    var body = {
      stateToken: recoveryTokenResource.stateToken,
      answer: account.profile.stormpathMigrationRecoveryAnswer
    };

    client.createResource(href, body, function (err, result) {

      if (err) {
        return callback(err);
      }

      var href = '/authn/credentials/reset_password';
      var body = {
        stateToken: result.stateToken,
        newPassword: newPassword
      };

      client.createResource(href, body, callback);

    });
  });
}
function resetPasswordWithRecoveryToken ( client , recoveryTokenResource , newPassword , callback ) { var userHref = '/users/' + recoveryTokenResource . _embedded . user . id ; client . getAccount ( userHref , function ( err , account ) { if ( err ) { return callback ( err ) ; } var href = '/authn/recovery/answer' ; var body = { stateToken : recoveryTokenResource . stateToken , answer : account . profile . stormpathMigrationRecoveryAnswer } ; client . createResource ( href , body , function ( err , result ) { if ( err ) { return callback ( err ) ; } var href = '/authn/credentials/reset_password' ; var body = { stateToken : result . stateToken , newPassword : newPassword } ; client . createResource ( href , body , callback ) ; } ) ; } ) ; }
Uses the AuthN API to complete a password reset workflow.

Use application.sendPasswordResetEmail() to get recoveryTokenResponse

@param {*} client stormpath client instance
@param {*} recoveryTokenResource the response from /authn/recovery/password
@param {*} newPassword new password that the end-user has provided
@param {*} callback
Uses the AuthN API to complete a password reset workflow .