@@ -13,6 +13,7 @@ import { AuthProvider } from '../common/authentication';
13
13
import { Disposable } from '../common/lifecycle' ;
14
14
import Logger from '../common/logger' ;
15
15
import * as PersistentState from '../common/persistentState' ;
16
+ import { GITHUB_ENTERPRISE , URI } from '../common/settingKeys' ;
16
17
import { ITelemetry } from '../common/telemetry' ;
17
18
import { agent } from '../env/node/net' ;
18
19
import { IAccount } from './interface' ;
@@ -213,8 +214,18 @@ export class CredentialStore extends Disposable {
213
214
private async doCreate ( options : vscode . AuthenticationGetSessionOptions , additionalScopes : boolean = false ) : Promise < AuthResult > {
214
215
const github = await this . initialize ( AuthProvider . github , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
215
216
let enterprise : AuthResult | undefined ;
217
+ const initializeEnterprise = ( ) => this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
216
218
if ( hasEnterpriseUri ( ) ) {
217
- enterprise = await this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
219
+ enterprise = await initializeEnterprise ( ) ;
220
+ } else {
221
+ // Listen for changes to the enterprise URI and try again if it changes.
222
+ const disposable = vscode . workspace . onDidChangeConfiguration ( async e => {
223
+ if ( e . affectsConfiguration ( `${ GITHUB_ENTERPRISE } .${ URI } ` ) && hasEnterpriseUri ( ) ) {
224
+ enterprise = await initializeEnterprise ( ) ;
225
+ disposable . dispose ( ) ;
226
+ }
227
+ } ) ;
228
+ this . context . subscriptions . push ( disposable ) ;
218
229
}
219
230
return {
220
231
canceled : github . canceled || ! ! ( enterprise && enterprise . canceled )
0 commit comments