Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added password reset features for tests #36

Merged
merged 3 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest /api/auth/local/reset/password-secret since REST endpoints' resources should be nouns and not verbs.. also, we don't need the / do we?

Copy link
Contributor Author

@sallakarppinen sallakarppinen Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll require me changing it in Hilary, 3akai as well so will take a bit longer. I'll go with /api/auth/local/reset/secret.

Also, I'm not sure which / you mean... We do need the ones here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secret is fine. And nevermind about the slashes, I misread the concatenation at the end

};

/**
* 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it /api/auth/local/reset/password since that's the resource we're manipulating

};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "oae-rest",
"main": "./lib/api.js",
"description": "Open Academic Environment (OAE) REST client library",
"version": "12.6.0",
"version": "13.0.1-1",
"homepage": "http://www.oaeproject.org",
"author": {
"name": "The Apereo Foundation",
Expand Down