@@ -50,26 +50,28 @@ export abstract class AzureDevOpsIntegrationBase<
50
50
51
51
const cachedAccount = this . _accounts . get ( accessToken ) ;
52
52
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 ) ;
68
55
}
69
56
70
57
return this . _accounts . get ( accessToken ) ;
71
58
}
72
59
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
+
73
75
private _organizations : Map < string , AzureOrganizationDescriptor [ ] | undefined > | undefined ;
74
76
private async getProviderResourcesForUser (
75
77
session : AuthenticationSession ,
@@ -615,6 +617,21 @@ export class AzureDevOpsServerIntegration extends AzureDevOpsIntegrationBase<Git
615
617
options . baseUrl = this . apiBaseUrl ;
616
618
return options ;
617
619
}
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
+ }
618
635
}
619
636
620
637
const 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