X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FAPI.js;h=95cdbcdd940689917fb6bcbe8d90b82f8ba32253;hb=6b61ca892507cab548b6eb56a07bc6d71ff40ab7;hp=30dc7b51534388267ab60ebb14775c1fd83e9f1b;hpb=fc5b9f1f68322c876b331c049749f113eb0271f7;p=blerg.git diff --git a/www/jssrc/blerg/API.js b/www/jssrc/blerg/API.js index 30dc7b5..95cdbcd 100644 --- a/www/jssrc/blerg/API.js +++ b/www/jssrc/blerg/API.js @@ -47,10 +47,10 @@ enyo.kind({ req.error(function() { this.bubble('onSignupFailure', {username: username}); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: username, password: password, - }); + })); }, login: function(username, password) { var req = new enyo.Ajax({ @@ -68,10 +68,10 @@ enyo.kind({ this.bubble('onLoginFailed'); } }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: username, password: password - }); + })); }, logout: function() { var req = new enyo.Ajax({ @@ -83,11 +83,29 @@ enyo.kind({ enyo.setCookie('auth', '', {"Max-Age": 0}); this.bubble('onLogoutSuccessful'); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); enyo.setCookie('username', '', {"Max-Age": 0}); }, + changePassword: function(oldpassword, newpassword) { + var req = new enyo.Ajax({ + url: baseURL + '/passwd', + method: 'POST' + }); + req.response(function(inSender, inResponse) { + if (inResponse.status == 'success') { + this.bubble('onPasswordChangeSuccessful'); + } else { + this.bubble('onPasswordChangeFailed'); + } + }.bind(this)); + req.go(enyo.Ajax.objectToQuery({ + username: blerg.API.username, + password: oldpassword, + new_password: newpassword + })); + }, loadUserRecords: function(username, from ,to) { var url; if (from != undefined && to != undefined) { @@ -155,9 +173,9 @@ enyo.kind({ req.response(function(inSender, inResponse) { this.bubble('onFeedInfo', inResponse); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); }, loadFeed: function() { if (!blerg.API.loggedIn) @@ -173,9 +191,9 @@ enyo.kind({ entries: inResponse }); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); }, getSubscriptionStatus: function(username) { var req = new enyo.Ajax({ @@ -188,9 +206,9 @@ enyo.kind({ subscribed: inResponse.subscribed }); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); }, subscribe: function(username) { var req = new enyo.Ajax({ @@ -203,9 +221,9 @@ enyo.kind({ subscribed: inResponse.status == "success" }); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); }, unsubscribe: function(username) { var req = new enyo.Ajax({ @@ -218,9 +236,9 @@ enyo.kind({ subscribed: inResponse.status != "success" }); }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username - }); + })); }, post: function(data) { var req = new enyo.Ajax({ @@ -240,9 +258,9 @@ enyo.kind({ }); } }.bind(this)); - req.go({ + req.go(enyo.Ajax.objectToQuery({ username: blerg.API.username, data: data - }); + })); } });