diff --git a/ExpressAPI/src/managers/GitlabManager.ts b/ExpressAPI/src/managers/GitlabManager.ts index b057966d5d504aaf64e54e91194859d8fe91536e..2a89593c1e362bdd7e12106fe101be9b0c1f86c1 100644 --- a/ExpressAPI/src/managers/GitlabManager.ts +++ b/ExpressAPI/src/managers/GitlabManager.ts @@ -12,6 +12,7 @@ import GitlabFile from '../shared/types/Gitlab/GitlabFile'; import express from 'express'; import GitlabRoute from '../shared/types/Gitlab/GitlabRoute'; import SharedConfig from '../shared/config/SharedConfig'; +import GitlabProfile from '../shared/types/Gitlab/GitlabProfile'; class GitlabManager { @@ -19,6 +20,20 @@ class GitlabManager { return `${ SharedConfig.gitlab.apiURL }${ route }`; } + public async getUserProfile(token: string): Promise<GitlabProfile | undefined> { + try { + return (await axios.get<GitlabProfile>(this.getApiUrl(GitlabRoute.PROFILE_GET), { + headers: { + DojoOverrideAuthorization: true, + DojoAuthorizationHeader : 'Authorization', + DojoAuthorizationValue : `Bearer ${ token }` + } + })).data; + } catch ( e ) { } + + return undefined; + } + public async getUserById(id: number): Promise<GitlabUser | undefined> { try { const params: any = {};