@@ -56,6 +56,11 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
56
56
return this . _didSignIn . event ;
57
57
}
58
58
59
+ private _didSignOut = new Emitter < void > ( ) ;
60
+ get onDidSignOut ( ) {
61
+ return this . _didSignOut . event ;
62
+ }
63
+
59
64
constructor (
60
65
@IFileService private readonly fileService : IFileService ,
61
66
@IStorageService private readonly storageService : IStorageService ,
@@ -162,11 +167,11 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
162
167
return [ ] ;
163
168
}
164
169
165
- public async initialize ( fromContinueOn : boolean ) {
170
+ public async initialize ( fromContinueOn : boolean , silent : boolean = false ) {
166
171
if ( this . initialized ) {
167
172
return true ;
168
173
}
169
- this . initialized = await this . doInitialize ( fromContinueOn ) ;
174
+ this . initialized = await this . doInitialize ( fromContinueOn , silent ) ;
170
175
this . signedInContext . set ( this . initialized ) ;
171
176
if ( this . initialized ) {
172
177
this . _didSignIn . fire ( ) ;
@@ -181,7 +186,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
181
186
* meaning that authentication is configured and it
182
187
* can be used to communicate with the remote storage service
183
188
*/
184
- private async doInitialize ( fromContinueOn : boolean ) : Promise < boolean > {
189
+ private async doInitialize ( fromContinueOn : boolean , silent : boolean ) : Promise < boolean > {
185
190
// Wait for authentication extensions to be registered
186
191
await this . extensionService . whenInstalledExtensionsRegistered ( ) ;
187
192
@@ -206,7 +211,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
206
211
return true ;
207
212
}
208
213
209
- const authenticationSession = await this . getAuthenticationSession ( fromContinueOn ) ;
214
+ const authenticationSession = await this . getAuthenticationSession ( fromContinueOn , silent ) ;
210
215
if ( authenticationSession !== undefined ) {
211
216
this . #authenticationInfo = authenticationSession ;
212
217
this . storeClient . setAuthToken ( authenticationSession . token , authenticationSession . providerId ) ;
@@ -239,14 +244,16 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
239
244
return currentMachineId ;
240
245
}
241
246
242
- private async getAuthenticationSession ( fromContinueOn : boolean ) {
247
+ private async getAuthenticationSession ( fromContinueOn : boolean , silent : boolean ) {
243
248
// If the user signed in previously and the session is still available, reuse that without prompting the user again
244
249
if ( this . existingSessionId ) {
245
250
this . logService . info ( `Searching for existing authentication session with ID ${ this . existingSessionId } ` ) ;
246
251
const existingSession = await this . getExistingSession ( ) ;
247
252
if ( existingSession ) {
248
253
this . logService . info ( `Found existing authentication session with ID ${ existingSession . session . id } ` ) ;
249
254
return { sessionId : existingSession . session . id , token : existingSession . session . idToken ?? existingSession . session . accessToken , providerId : existingSession . session . providerId } ;
255
+ } else {
256
+ this . _didSignOut . fire ( ) ;
250
257
}
251
258
}
252
259
@@ -261,6 +268,12 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
261
268
}
262
269
}
263
270
271
+ // If we aren't supposed to prompt the user because
272
+ // we're in a silent flow, just return here
273
+ if ( silent ) {
274
+ return ;
275
+ }
276
+
264
277
// Ask the user to pick a preferred account
265
278
const authenticationSession = await this . getAccountPreference ( fromContinueOn ) ;
266
279
if ( authenticationSession !== undefined ) {
0 commit comments