Skip to content

Commit 50dde07

Browse files
committed
temp for auth
1 parent 2f0829b commit 50dde07

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/commands/showPanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ async function handleMessage(
6969
}
7070
if (editor !== activeEditor) {
7171
console.log(
72-
`EXTENSION: Editor ${editor.assessmentName}_${editor.questionId} is no longer active, skipping onChange`,
72+
`EXTENSION: Editor is no longer active, skipping onChange`,
73+
`User edited ${editor.assessmentName}_${editor.questionId}, active is ${activeEditor?.assessmentName}_${activeEditor?.questionId}`,
7374
);
75+
return;
7476
}
7577
const message = Messages.Text(workspaceLocation, code);
7678
console.log(`Sending message: ${JSON.stringify(message)}`);
@@ -91,7 +93,8 @@ async function handleMessage(
9193
handling = false;
9294
}
9395

94-
export async function showPanel(context: vscode.ExtensionContext) {
96+
export async function showPanel(context: vscode.ExtensionContext, url: string) {
97+
vscode.window.showInformationMessage(`showPanel caleld with ${url}`);
9598
let language: string | undefined = context.workspaceState.get("language");
9699
if (!language) {
97100
language = LANGUAGES.SOURCE_1;
@@ -129,7 +132,8 @@ export async function showPanel(context: vscode.ExtensionContext) {
129132
>
130133
<iframe
131134
id={FRONTEND_ELEMENT_ID}
132-
src={frontendUrl}
135+
src={url || frontendUrl}
136+
// src={"vscode://source-academy.source-academy/sso"}
133137
width="100%"
134138
height="100%"
135139
// @ts-ignore

src/extension.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from "vscode";
44
import { setupStatusBar } from "./statusbar/status";
55
import { registerAllCommands } from "./commands";
66
import { activateLspClient, deactivateLspClient } from "./lsp/client";
7+
import { showPanel } from "./commands/showPanel";
78

89
// This method is called when your extension is activated
910
// Your extension is activated the very first time the command is executed
@@ -16,12 +17,17 @@ export function activate(context: vscode.ExtensionContext) {
1617
vscode.window.registerUriHandler({
1718
handleUri(uri: vscode.Uri) {
1819
const searchParams = new URLSearchParams(uri.query);
19-
const accessToken = searchParams.get("access_token");
20-
vscode.window.showInformationMessage(`Access: ${accessToken}`);
21-
const refreshToken = searchParams.get("refresh_token");
22-
vscode.window.showInformationMessage(`Refresh: ${refreshToken}`);
20+
const code = searchParams.get("code");
21+
vscode.window.showInformationMessage(`Code: ${code}`);
22+
const provider = searchParams.get("provider");
23+
vscode.window.showInformationMessage(`Provider: ${provider}`);
2324

24-
context.globalState.update("token", { accessToken, refreshToken });
25+
// context.globalState.update("token", {
26+
// accessToken: code,
27+
// refreshToken: provider,
28+
// });
29+
const url = `http://localhost:4000/v2/auth/exchange/?code=${code}&provider=${provider}`;
30+
showPanel(context, url);
2531
},
2632
});
2733
}

0 commit comments

Comments
 (0)