Skip to content

Commit

Permalink
fix: toggle between signin signout (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak Shyngle <[email protected]>
  • Loading branch information
Sarthak160 authored Aug 28, 2024
1 parent 212aa4d commit ffc3da2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dist
node_modules
.vscode-test/
intellijpublish.yml
*.log
*.log
out
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@
"title": "Sign Out",
"when": "keploy.signedOut != true && view == Keploy-Sidebar"
},
{
"command": "keploy.SignOut",
"title": "Sign Out",
"when": "keploy.signedOut != true && view == Keploy-Sidebar"
},
{
"command": "keploy.utg",
"title": "Keploy: Unit Test Generation"
Expand Down
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export function activate(context: vscode.ExtensionContext) {
// Disable the sign-in command since the user is already signed in
vscode.commands.executeCommand('setContext', 'keploy.signedIn', true);
vscode.window.showInformationMessage('You are already signed in!');
// enable the signout command
vscode.commands.executeCommand('setContext', 'keploy.signedOut', false);

} else {
vscode.commands.executeCommand('setContext', 'keploy.signedOut', true);
// Register the sign-in command if not signed in
let signInCommand = vscode.commands.registerCommand('keploy.SignIn', async () => {
try {
Expand All @@ -110,11 +114,13 @@ export function activate(context: vscode.ExtensionContext) {
const { emailID, isValid, error } = await validateFirst(accessToken, "https://api.keploy.io");

// if (isValid) {
vscode.window.showInformationMessage('You are now signed in!');
vscode.commands.executeCommand('setContext', 'keploy.signedIn', true);
vscode.window.showInformationMessage('You are now signed in!');
vscode.commands.executeCommand('setContext', 'keploy.signedIn', true);
vscode.commands.executeCommand('setContext', 'keploy.signedOut', false);
// } else {
// console.log('Validation failed for the user !');
// }

} else {
console.log('Failed to get the session or email.');
vscode.window.showInformationMessage('Failed to sign in Keploy!');
Expand All @@ -133,6 +139,7 @@ export function activate(context: vscode.ExtensionContext) {
context.globalState.update('accessToken', undefined);
vscode.window.showInformationMessage('You have been signed out.');
vscode.commands.executeCommand('setContext', 'keploy.signedIn', false);
vscode.commands.executeCommand('setContext', 'keploy.signedOut', true);
});

context.subscriptions.push(signout);
Expand Down

0 comments on commit ffc3da2

Please sign in to comment.