Skip to content

Commit 57684d7

Browse files
author
Toehio
committed
Describe the currently authenticated user
1 parent 555ffa6 commit 57684d7

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

lib/jira.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,4 +1600,56 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
16001600
});
16011601
};
16021602

1603+
1604+
// ## Describe the currently authenticated user ##
1605+
// ### Takes ###
1606+
//
1607+
// * callback: for when it's done
1608+
//
1609+
// ### Returns ###
1610+
// * error string
1611+
// * user object
1612+
//
1613+
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id2e865)
1614+
/*
1615+
* User object in the format:
1616+
* {
1617+
* self: 'http://localhost:8090/rest/api/latest/user?username=user',
1618+
* name: 'user',
1619+
* loginInfo:
1620+
* {
1621+
* failedLoginCount: 2,
1622+
* loginCount: 114,
1623+
* lastFailedLoginTime: '2013-10-29T13:33:26.702+0000',
1624+
* previousLoginTime: '2013-10-31T20:30:51.924+0000'
1625+
* }
1626+
* }
1627+
*/
1628+
1629+
this.getCurrentUser = function(callback) {
1630+
var options = {
1631+
rejectUnauthorized: this.strictSSL,
1632+
uri: this.makeUri('/session', 'rest/auth/', '1'),
1633+
method: 'GET',
1634+
json: true
1635+
};
1636+
1637+
this.request(options, function(error, response, body) {
1638+
1639+
if (error) {
1640+
callback(error, null);
1641+
return;
1642+
}
1643+
1644+
if (response.statusCode === 200) {
1645+
callback(null, body);
1646+
return;
1647+
}
1648+
1649+
callback(response.statusCode + ': Error while deleting webhook');
1650+
1651+
});
1652+
};
1653+
1654+
16031655
}).call(JiraApi.prototype);

0 commit comments

Comments
 (0)