File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,31 @@ class Client {
250250 }
251251 }
252252
253+ /**
254+ * Retrieves info about the current logged-in user
255+ *
256+ * @returns Object containing user info
257+ **/
258+ async getUserInfo ( ) {
259+ await this . login ( )
260+
261+ const url = libUtil . joinUrl ( this . apiUrl . href , `${ defaultApiVersion } /users` )
262+ let userInfo
263+ try {
264+ userInfo = await simpleRequester . do ( { url, accessToken : this . accessToken , json : true } )
265+ } catch ( e ) {
266+ if ( e . status !== 401 ) {
267+ throw e
268+ }
269+ const tokens = await refresh . do ( this . accessToken , this . refreshToken , this . apiUrl )
270+ this . accessToken = tokens . access
271+ this . refreshToken = tokens . refresh
272+
273+ userInfo = await simpleRequester . do ( { url, accessToken : this . accessToken , json : true } )
274+ }
275+ return userInfo
276+ }
277+
253278 async getStatus ( uuid , inputApiUrl = defaultApiUrl ) {
254279 const url = libUtil . joinUrl ( this . apiUrl . href , `${ defaultApiVersion } /analyses/${ uuid } ` )
255280 return this . getStatusOrIssues ( uuid , url , inputApiUrl )
You can’t perform that action at this time.
0 commit comments