Add password change functionality
[blerg.git] / www / jssrc / blerg / API.js
index 30dc7b5..4a0602b 100644 (file)
@@ -88,6 +88,24 @@ enyo.kind({
         });
         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({
+            username: blerg.API.username,
+            password: oldpassword,
+            new_password: newpassword
+        });
+    },
     loadUserRecords: function(username, from ,to) {
         var url;
         if (from != undefined && to != undefined) {