@@ -24,6 +24,7 @@ import type { LogScope } from '../../system/logger.scope';
2424import { getLogScope } from '../../system/logger.scope' ;
2525import type {
2626 IntegrationAuthenticationProviderDescriptor ,
27+ IntegrationAuthenticationService ,
2728 IntegrationAuthenticationSessionDescriptor ,
2829} from './authentication/integrationAuthentication' ;
2930import type { ProviderAuthenticationSession } from './authentication/models' ;
@@ -88,6 +89,7 @@ export abstract class IntegrationBase<
8889
8990 constructor (
9091 protected readonly container : Container ,
92+ protected readonly authenticationService : IntegrationAuthenticationService ,
9193 protected readonly getProvidersApi : ( ) => Promise < ProvidersApi > ,
9294 ) { }
9395
@@ -125,7 +127,7 @@ export abstract class IntegrationBase<
125127 }
126128
127129 protected _session : ProviderAuthenticationSession | null | undefined ;
128- protected session ( ) {
130+ getSession ( ) {
129131 if ( this . _session === undefined ) {
130132 return this . ensureSession ( false ) ;
131133 }
@@ -151,40 +153,38 @@ export abstract class IntegrationBase<
151153
152154 const connected = this . _session != null ;
153155
154- if ( connected && ! options ?. silent ) {
155- if ( options ?. currentSessionOnly ) {
156- void showIntegrationDisconnectedTooManyFailedRequestsWarningMessage ( this . name ) ;
156+ let signOut = ! options ?. currentSessionOnly ;
157+
158+ if ( connected && ! options ?. currentSessionOnly && ! options ?. silent ) {
159+ const disable = { title : 'Disable' } ;
160+ const disableAndSignOut = { title : 'Disable & Sign Out' } ;
161+ const cancel = { title : 'Cancel' , isCloseAffordance : true } ;
162+
163+ let result : MessageItem | undefined ;
164+ if ( this . authenticationService . supports ( this . authProvider . id ) ) {
165+ result = await window . showWarningMessage (
166+ `Are you sure you want to disable the rich integration with ${ this . name } ?\n\nNote: signing out clears the saved authentication.` ,
167+ { modal : true } ,
168+ disable ,
169+ disableAndSignOut ,
170+ cancel ,
171+ ) ;
157172 } else {
158- const disable = { title : 'Disable' } ;
159- const signout = { title : 'Disable & Sign Out' } ;
160- const cancel = { title : 'Cancel' , isCloseAffordance : true } ;
161-
162- let result : MessageItem | undefined ;
163- if ( this . container . integrationAuthentication . supports ( this . authProvider . id ) ) {
164- result = await window . showWarningMessage (
165- `Are you sure you want to disable the rich integration with ${ this . name } ?\n\nNote: signing out clears the saved authentication.` ,
166- { modal : true } ,
167- disable ,
168- signout ,
169- cancel ,
170- ) ;
171- } else {
172- result = await window . showWarningMessage (
173- `Are you sure you want to disable the rich integration with ${ this . name } ?` ,
174- { modal : true } ,
175- disable ,
176- cancel ,
177- ) ;
178- }
179-
180- if ( result == null || result === cancel ) return ;
181- if ( result === signout ) {
182- void this . container . integrationAuthentication . deleteSession (
183- this . authProvider . id ,
184- this . authProviderDescriptor ,
185- ) ;
186- }
173+ result = await window . showWarningMessage (
174+ `Are you sure you want to disable the rich integration with ${ this . name } ?` ,
175+ { modal : true } ,
176+ disable ,
177+ cancel ,
178+ ) ;
187179 }
180+
181+ if ( result == null || result === cancel ) return ;
182+
183+ signOut = result === disableAndSignOut ;
184+ }
185+
186+ if ( signOut ) {
187+ void this . authenticationService . deleteSession ( this . authProvider . id , this . authProviderDescriptor ) ;
188188 }
189189
190190 this . resetRequestExceptionCount ( ) ;
@@ -241,14 +241,15 @@ export abstract class IntegrationBase<
241241 this . requestExceptionCount ++ ;
242242
243243 if ( this . requestExceptionCount >= 5 && this . _session !== null ) {
244+ void showIntegrationDisconnectedTooManyFailedRequestsWarningMessage ( this . name ) ;
244245 void this . disconnect ( { currentSessionOnly : true } ) ;
245246 }
246247 }
247248
248249 @gate ( )
249250 @debug ( { exit : true } )
250251 async isConnected ( ) : Promise < boolean > {
251- return ( await this . session ( ) ) != null ;
252+ return ( await this . getSession ( ) ) != null ;
252253 }
253254
254255 @gate ( )
@@ -267,11 +268,10 @@ export abstract class IntegrationBase<
267268
268269 let session : ProviderAuthenticationSession | undefined | null ;
269270 try {
270- session = await this . container . integrationAuthentication . getSession (
271- this . authProvider . id ,
272- this . authProviderDescriptor ,
273- { createIfNeeded : createIfNeeded , forceNewSession : forceNewSession } ,
274- ) ;
271+ session = await this . authenticationService . getSession ( this . authProvider . id , this . authProviderDescriptor , {
272+ createIfNeeded : createIfNeeded ,
273+ forceNewSession : forceNewSession ,
274+ } ) ;
275275 } catch ( ex ) {
276276 await this . container . storage . deleteWorkspace ( this . connectedKey ) ;
277277
0 commit comments