Skip to content

Commit

Permalink
Added password reset features for test
Browse files Browse the repository at this point in the history
  • Loading branch information
Salla Karppinen committed Jun 20, 2017
1 parent 42b4cef commit 1655e7a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/api.authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,29 @@ var shibbolethTenantCallback = module.exports.shibbolethTenantCallback = functio
var ldapLogin = module.exports.ldapLogin = function(restCtx, username, password, callback) {
RestUtil.RestRequest(restCtx, '/api/auth/ldap', 'POST', {'username': username, 'password': password}, callback);
};

/**
* Get a secret token to be used to reset password
*
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL
* @param {String} username The username for which a password needs to be reset
* @param {Function} callback Standard callback method
* @param {Object} callback.err An error that occurred, if any
*/
var getResetPasswordSecret = module.exports.getResetPasswordSecret = function(restCtx, username, callback) {
RestUtil.RestRequest(restCtx, '/api/auth/local/reset/init/' + username, 'GET', null, callback);
};

/**
* Reset a password for a user using a token
*
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL
* @param {String} username The username for which a password needs to be reset
* @param {String} secret The token identifying the user trying to reset their password
* @param {String} newPassword The new password to reset
* @param {Function} callback Standard callback method
* @param {Object} callback.err An error that occurred, if any
*/
var resetPassword = module.exports.resetPassword = function(restCtx, username, secret, newPassword, callback) {
RestUtil.RestRequest(restCtx, '/api/auth/local/reset/change/' + username, 'POST', {'secret': secret, 'newPassword': newPassword}, callback);
};

0 comments on commit 1655e7a

Please sign in to comment.