diff --git a/src/extension/extension.ts b/src/extension/extension.ts index ed6c6aef0..88c17e581 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -454,8 +454,8 @@ export class RunmeExtension { const statefulAuthProvider = new StatefulAuthProvider(context, uriHandler) context.subscriptions.push(statefulAuthProvider) - const secrestAuthed = statefulAuthProvider.loadFromSecrets() - const forceLogin = kernel.isFeatureOn(FeatureName.ForceLogin) || (await secrestAuthed) + const secrestAuthed = await statefulAuthProvider.loadFromSecrets() + const forceLogin = kernel.isFeatureOn(FeatureName.ForceLogin) || secrestAuthed const silent = forceLogin ? undefined : true getPlatformAuthSession(forceLogin, silent) diff --git a/src/extension/provider/statefulAuth.ts b/src/extension/provider/statefulAuth.ts index d53eb4783..53fe532c6 100644 --- a/src/extension/provider/statefulAuth.ts +++ b/src/extension/provider/statefulAuth.ts @@ -239,11 +239,6 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable public async loadFromSecrets() { const secretsFile = '/etc/secrets/playground-dev' - if (!secretsFile) { - logger.info('Skip authentication from secrets file') - return - } - const secretsUri = Uri.parse(secretsFile) const hasSecretsFile = await workspace.fs.stat(secretsUri).then( () => true, @@ -251,7 +246,7 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable ) if (!hasSecretsFile) { - logger.info('No secrets file found') + logger.info('No secrets file found, skipping load from secrets') return } @@ -276,6 +271,12 @@ export class StatefulAuthProvider implements AuthenticationProvider, Disposable try { const { name, email } = await this.getUserInfo(token) + + if (!name || !email) { + logger.error('Failed to get user info from JWT token') + return + } + const session: StatefulAuthSession = { accessToken: token, expiresIn: secsToUnixTime(exp),