From b5ddbfbc7558dbdf2c7291598dd9d8face1fa229 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 6 May 2013 19:46:17 +0200 Subject: Reset Password Feature (front end only) --- cloud.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'cloud.js') diff --git a/cloud.js b/cloud.js index 9245286..f3396d8 100644 --- a/cloud.js +++ b/cloud.js @@ -29,7 +29,7 @@ /*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/ -modules.cloud = '2013-April-19'; +modules.cloud = '2013-May-06'; // Global stuff @@ -37,7 +37,7 @@ var Cloud; var SnapCloud = new Cloud( 'https://snapcloud.miosoft.com/miocon/app/login?_app=SnapCloud' - //'192.168.2.108:8087/miocon/app/login?_app=SnapCloud' + //'192.168.2.110:8087/miocon/app/login?_app=SnapCloud' //'192.168.186.167:8087/miocon/app/login?_app=SnapCloud' // 'localhost/miocon/app/login?_app=SnapCloud' ); @@ -178,6 +178,62 @@ Cloud.prototype.getPublicProject = function ( } }; +Cloud.prototype.resetPassword = function ( + username, + email, + callBack, + errorCall +) { + // both callBack and errorCall are two-argument functions + var request = new XMLHttpRequest(), + myself = this; + try { + request.open( + "GET", + (this.hasProtocol() ? '' : 'http://') + + this.url + 'ResetPW' + + '&Username=' + + encodeURIComponent(username) + + '&Email=' + + email, + true + ); + request.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); + request.withCredentials = true; + request.onreadystatechange = function () { + if (request.readyState === 4) { + if (request.responseText) { + if (request.responseText.indexOf('ERROR') === 0) { + errorCall.call( + this, + request.responseText, + 'Reset Password' + ); + } else { + callBack.call( + null, + request.responseText, + 'Reset Password' + ); + } + } else { + errorCall.call( + null, + myself.url + 'ResetPW', + 'could not connect to:' + ); + } + } + }; + request.send(null); + } catch (err) { + errorCall.call(this, err.toString(), 'Snap!Cloud'); + } +}; + Cloud.prototype.connect = function ( callBack, errorCall -- cgit v1.3.1