Skip to content

Commit 6f93f8b

Browse files
committed
Added the whoAmI method
1 parent 19609ec commit 6f93f8b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/kuzzle.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,23 @@ Kuzzle.prototype.checkToken = function (token, callback) {
453453
return self;
454454
};
455455

456+
/**
457+
* Fetches the current user.
458+
*
459+
* @param {function} callback The callback to be called when the response is
460+
* available. The signature is `function(error, response)`.
461+
* @return {Kuzzle} The Kuzzle instance to enable chaining.
462+
*/
463+
Kuzzle.prototype.whoAmI = function (callback) {
464+
var self = this;
465+
466+
this.callbackRequired('Kuzzle.checkToken', callback);
467+
468+
this.query({controller: 'auth', action: 'getCurrentUser'}, {}, {}, callback);
469+
470+
return self;
471+
};
472+
456473
/**
457474
* Clean up the queue, ensuring the queryTTL and queryMaxSize properties are respected
458475
*/

0 commit comments

Comments
 (0)