@@ -50,26 +50,28 @@ export abstract class AzureDevOpsIntegrationBase<
5050
5151 const cachedAccount = this . _accounts . get ( accessToken ) ;
5252 if ( cachedAccount == null ) {
53- const api = await this . getProvidersApi ( ) ;
54- const user = await api . getCurrentUser ( this . id , this . getApiOptions ( accessToken , true ) ) ;
55- this . _accounts . set (
56- accessToken ,
57- user
58- ? {
59- provider : this ,
60- id : user . id ,
61- name : user . name ?? undefined ,
62- email : user . email ?? undefined ,
63- avatarUrl : user . avatarUrl ?? undefined ,
64- username : user . username ?? undefined ,
65- }
66- : undefined ,
67- ) ;
53+ const user = await this . _requestForCurrentUser ( accessToken ) ;
54+ this . _accounts . set ( accessToken , user ) ;
6855 }
6956
7057 return this . _accounts . get ( accessToken ) ;
7158 }
7259
60+ protected async _requestForCurrentUser ( accessToken : string ) : Promise < Account | undefined > {
61+ const api = await this . getProvidersApi ( ) ;
62+ const user = await api . getCurrentUser ( this . id , this . getApiOptions ( accessToken , true ) ) ;
63+ return user
64+ ? {
65+ provider : this ,
66+ id : user . id ,
67+ name : user . name ?? undefined ,
68+ email : user . email ?? undefined ,
69+ avatarUrl : user . avatarUrl ?? undefined ,
70+ username : user . username ?? undefined ,
71+ }
72+ : undefined ;
73+ }
74+
7375 private _organizations : Map < string , AzureOrganizationDescriptor [ ] | undefined > | undefined ;
7476 private async getProviderResourcesForUser (
7577 session : AuthenticationSession ,
@@ -615,6 +617,21 @@ export class AzureDevOpsServerIntegration extends AzureDevOpsIntegrationBase<Git
615617 options . baseUrl = this . apiBaseUrl ;
616618 return options ;
617619 }
620+
621+ protected override async _requestForCurrentUser ( accessToken : string ) : Promise < Account | undefined > {
622+ const azure = await this . container . azure ;
623+ const user = azure ? await azure . getCurrentUserOnServer ( this , accessToken , this . apiBaseUrl ) : undefined ;
624+ return user
625+ ? {
626+ provider : this ,
627+ id : user . id ,
628+ name : user . name ?? undefined ,
629+ email : user . email ?? undefined ,
630+ avatarUrl : user . avatarUrl ?? undefined ,
631+ username : user . username ?? undefined ,
632+ }
633+ : undefined ;
634+ }
618635}
619636
620637const azureCloudDomainRegex = / ^ d e v \. a z u r e \. c o m $ | \b v i s u a l s t u d i o \. c o m $ / i;
0 commit comments