Skip to content
Snippets Groups Projects
Commit 6ad2a492 authored by Christian ZHENG's avatar Christian ZHENG
Browse files

chore(login): minor refactor

parent dfb714b3
Branches
Tags
3 merge requests!16feat: publish extension on marketplace with ci,!15feat(Sprint1): add authentication + directory picking + redirection link,!14sprint 1
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment