Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

INT-1902 Handle account session expiry #822

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "intuita-vscode-extension",
"displayName": "Intuita",
"description": " Discover, run & manage codemods faster & easier.",
"version": "0.36.13",
"version": "0.36.14",
"publisher": "Intuita",
"icon": "img/intuita_square128.png",
"repository": {
Expand Down
29 changes: 24 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,31 @@ export async function activate(context: vscode.ExtensionContext) {
const userService = new UserService(globalStateTokenStorage);

const accessToken = userService.getLinkedToken();
if (accessToken !== null) {
const valid = await validateAccessToken(accessToken);
vscode.commands.executeCommand('setContext', 'intuita.signedIn', valid);

if (!valid) {
userService.unlinkUserIntuitaAccount();
const decision = await vscode.window.showInformationMessage(
'You are signed out because your session has expired.',
'Do you want to sign in again?',
);
if (decision === 'Do you want to sign in again?') {
const searchParams = new URLSearchParams();

vscode.commands.executeCommand(
'setContext',
'intuita.signedIn',
accessToken !== null,
);
searchParams.set(
SEARCH_PARAMS_KEYS.COMMAND,
'accessTokenRequested',
);

const url = new URL('https://codemod.studio');
url.search = searchParams.toString();

vscode.commands.executeCommand('intuita.redirect', url);
}
}
}

const configurationContainer = buildContainer(getConfiguration());

Expand Down