From 6ad2a492554d8eec0e7ad8eefa5587561dfb4d44 Mon Sep 17 00:00:00 2001 From: Christian Zheng <czheng@takima.fr> Date: Wed, 13 Apr 2022 13:50:32 +0200 Subject: [PATCH] chore(login): minor refactor --- .../deadlock-extension/src/core/controller.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/deadlock-plugins/deadlock-extension/src/core/controller.ts b/deadlock-plugins/deadlock-extension/src/core/controller.ts index afee4a86..bf1a9ed2 100644 --- a/deadlock-plugins/deadlock-extension/src/core/controller.ts +++ b/deadlock-plugins/deadlock-extension/src/core/controller.ts @@ -9,7 +9,7 @@ import KeycloakOAuth2DeviceFlowConnection from './keycloakOAuth2DeviceFlowConnec export default class Controller { public connection: KeycloakOAuth2DeviceFlowConnection; private commandHandler: CommandHandler; - private briefingView; + private briefingView: BriefingView; private gettingStartedView: GettingStartedView; constructor(private context: vscode.ExtensionContext) { this.briefingView = new BriefingView(); @@ -21,6 +21,9 @@ export default class Controller { 'https://auth.dev.deadlock.io/auth/realms/Deadlock/protocol/openid-connect/userinfo', ); + this.init(); + } + private async init() { const that = this; vscode.window.registerUriHandler({ handleUri(uri: vscode.Uri) { @@ -37,20 +40,18 @@ export default class Controller { } }, }); - this.init(); - } - async init() { + const exensionStorage = ExtensionStore.getInstance(); this.gettingStartedView.isAlreadyConnected = !!(await exensionStorage.getAccessToken()); } - async clear() { + public async clear() { const exensionStorage = ExtensionStore.getInstance(); await exensionStorage.clear(); this.gettingStartedView.isAlreadyConnected = false; } - async authenticate() { + public async authenticate() { // WARN generate a new device code every time student clicks on log in button. Should I keep it ?\ // The answer might be 'yes' because when the student is already authenticated, the log in button should be disabled. await this.connection.registerDevice(); @@ -64,7 +65,7 @@ export default class Controller { vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url)); } - async launchMission(missionId: string | null) { + public async launchMission(missionId: string | null) { if (missionId) { vscode.window.showInformationMessage(`vous lancez la mission ${missionId}`); const extensionStore = ExtensionStore.getInstance(); -- GitLab