From 158be149ea6bdb73f26fcdcac026735d30e2c628 Mon Sep 17 00:00:00 2001 From: Bernat Romagosa Date: Fri, 10 Nov 2017 12:19:21 +0100 Subject: [PATCH] change password --- cloud.js | 19 +++++++++++++++++-- gui.js | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cloud.js b/cloud.js index d301835d..5c67b64d 100644 --- a/cloud.js +++ b/cloud.js @@ -251,19 +251,34 @@ Cloud.prototype.login = function (username, password, persist, onSuccess, onErro ); }; -Cloud.prototype.signup = function (username, password, password_repeat, email, onSuccess, onError){ +Cloud.prototype.signup = function (username, password, passwordRepeat, email, onSuccess, onError) { this.request( 'POST', '/users/' + username + '?' + this.encodeDict({ email: email, password: password, - password_repeat: password_repeat + password_repeat: passwordRepeat }), onSuccess, onError, 'signup failed'); }; +Cloud.prototype.changePassword = function (password, newPassword, passwordRepeat, onSuccess, onError) { + this.withCredentialsRequest( + 'POST', + '/users/%username/newpassword?' + this.encodeDict({ + oldpassword: password, + password_repeat: passwordRepeat, + newpassword: newPassword + }), + onSuccess, + onError, + 'Could not change password' + ); + +}; + // Projects Cloud.prototype.saveProject = function (ide, onSuccess, onError) { diff --git a/gui.js b/gui.js index 832c2582..a37cf2c7 100644 --- a/gui.js +++ b/gui.js @@ -5199,8 +5199,8 @@ IDE_Morph.prototype.changeCloudPassword = function () { SnapCloud.changePassword( user.oldpassword, user.password, + user.passwordRepeat, function () { - myself.logout(); myself.showMessage('password has been changed.', 2); }, myself.cloudError()