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

Commit

Permalink
Handle account session expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Sep 20, 2023
1 parent fb057ba commit a2022fd
Showing 1 changed file with 24 additions and 5 deletions.
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

0 comments on commit a2022fd

Please sign in to comment.