diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 05c1e49b1..87104bbb2 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -489,15 +489,21 @@ export class RunmeExtension { } if (kernel.isFeatureOn(FeatureName.RequireStatefulAuth)) { - await StatefulAuthProvider.instance.ensureSession() - StatefulAuthProvider.instance.currentSession().then(async (session) => { - if (session) { - await commands.executeCommand('runme.lifecycleIdentitySelection', RunmeIdentity.ALL) + const logger = getLogger(FeatureName.RequireStatefulAuth) + try { + const session = await StatefulAuthProvider.instance.ensureSession() + const nunmeIdentity = session ? RunmeIdentity.ALL : getServerLifecycleIdentity() + await commands.executeCommand('runme.lifecycleIdentitySelection', nunmeIdentity) + } catch (error) { + let message + if (error instanceof Error) { + message = error.message } else { - const settingsDefault = getServerLifecycleIdentity() - await commands.executeCommand('runme.lifecycleIdentitySelection', settingsDefault) + message = JSON.stringify(error) } - }) + + logger.error(message) + } } if (kernel.isFeatureOn(FeatureName.Gist)) { diff --git a/src/extension/provider/statefulAuth.ts b/src/extension/provider/statefulAuth.ts index 3e3013857..5b2af2f7a 100644 --- a/src/extension/provider/statefulAuth.ts +++ b/src/extension/provider/statefulAuth.ts @@ -136,11 +136,11 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable return sessions[0] } - async ensureSession() { + async ensureSession(): Promise { let session = await this.currentSession() if (session) { StatefulAuthProvider.showLoginNotification() - return + return session } session = await StatefulAuthProvider.bootstrapFromToken() @@ -148,10 +148,11 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable const silent = forceLogin ? undefined : true - this.newSession(silent) + return this.newSession(silent) .then(() => { if (session) { StatefulAuthProvider.showLoginNotification() + return session } }) .catch((error) => { @@ -170,6 +171,7 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable if (forceLogin && message === 'User did not consent to login.') { authentication.getSession(AuthenticationProviders.Stateful, DEFAULT_SCOPES, {}) } + return error }) }