Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
feat: adds Command to remove auth token from local config
Browse files Browse the repository at this point in the history
It should be possible to remove your API token from the IDE
  • Loading branch information
thisislawatts committed Apr 10, 2020
1 parent 77dc018 commit 7baa5f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
"command": "vulnCost.signIn",
"title": "Snyk: Signup/create a Snyk account"
},
{
"command": "vulnCost.signOut",
"title": "Snyk: Sign out"
},
{
"command": "vulnCost.showOutput",
"title": "Snyk: Show vulnerability report"
Expand Down
12 changes: 11 additions & 1 deletion src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as vscode from 'vscode';
import { calculated, flushDecorations, clearDecorations, clearShown} from './decorator';
import logger from './logger';
import { SnykVulnInfo } from './SnykAction';
import { isAuthed, setToken } from './getImports/snykAPI';
import { isAuthed, setToken, clearToken } from './getImports/snykAPI';
import { refreshDiagnostics } from './diagnostics';
import { v4 as uuidv4 } from 'uuid';
import authenticate from './authenticate';
Expand Down Expand Up @@ -88,6 +88,16 @@ export function activate(context) {
})
);

context.subscriptions.push(
commands.registerCommand('vulnCost.signOut', () => {
window.showInformationMessage('Removing auth token');

clearToken();

return;
})
);

context.subscriptions.push(
commands.registerCommand('vulnCost.signIn', () => {
if (isAuthed()) {
Expand Down
4 changes: 4 additions & 0 deletions src/getImports/snykAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export const setToken = t => {

export const getToken = () => token;

export const clearToken = () => {
userConfig.delete('api');
}

export default token;

0 comments on commit 7baa5f8

Please sign in to comment.