usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [35/68] [abbrv] incubator-usergrid git commit: Adding admin login function to Client.js
Date Fri, 17 Apr 2015 22:47:40 GMT
Adding admin login function to Client.js

Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d83342e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d83342e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d83342e0

Branch: refs/heads/two-dot-o-dev
Commit: d83342e0d9d6dd56bdb236d43dce70f68ca1d37b
Parents: 867c6dd
Author: Pahan Perera <pahan.madushanka@gmail.com>
Authored: Sat Jan 17 09:38:27 2015 +0530
Committer: Pahan Perera <pahan.madushanka@gmail.com>
Committed: Sat Jan 17 09:38:27 2015 +0530

----------------------------------------------------------------------
 sdks/html5-javascript/lib/modules/Client.js | 29 +++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d83342e0/sdks/html5-javascript/lib/modules/Client.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/modules/Client.js b/sdks/html5-javascript/lib/modules/Client.js
index 8f2ed28..e27ae65 100644
--- a/sdks/html5-javascript/lib/modules/Client.js
+++ b/sdks/html5-javascript/lib/modules/Client.js
@@ -552,7 +552,34 @@
       doCallback(callback, [err, response, user]);
     });
   };
-
+  
+  Usergrid.Client.prototype.adminlogin = function(username, password, callback) {
+    var self = this;
+    var options = {
+        method: "POST",
+        endpoint:'management/token',
+        body: {
+            username: username,
+            password: password,
+            grant_type: "password"
+        },
+        mQuery:true
+    };
+    self.request(options, function(err, response) {
+        var user = {};
+        if (err) {
+            if (self.logging) console.log("error trying to log adminuser in");
+        } else {
+            var options = {
+                client: self,
+                data: response.user
+            };
+            user = new Usergrid.Entity(options);
+            self.setToken(response.access_token);
+        }
+        doCallback(callback, [ err, response, user ]);
+    });
+  };
 
   Usergrid.Client.prototype.reAuthenticateLite = function(callback) {
     var self = this;


Mime
View raw message