File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 5050 "command" : " gitguardian.authenticate" ,
5151 "title" : " gitguardian: Authenticate"
5252 },
53+ {
54+ "command" : " gitguardian.logout" ,
55+ "title" : " gitguardian: logout"
56+ },
5357 {
5458 "command" : " gitguardian.showOutput" ,
5559 "title" : " Show Output"
Original file line number Diff line number Diff line change 55 ignoreLastFound ,
66 ignoreSecret ,
77 loginGGShield ,
8+ logoutGGShield ,
89 showAPIQuota ,
910} from "./lib/ggshield-api" ;
1011import {
@@ -255,6 +256,16 @@ export function activate(context: ExtensionContext) {
255256 } else {
256257 updateStatusBarItem ( StatusBarStatus . unauthenticated , statusBar ) ;
257258 }
259+ } ) ,
260+ commands . registerCommand ( "gitguardian.logout" , async ( ) => {
261+ outputChannel . show ( ) ;
262+ logoutGGShield ( ggshieldResolver . configuration ) ;
263+ updateStatusBarItem ( StatusBarStatus . unauthenticated , statusBar ) ;
264+ commands . executeCommand ( 'setContext' , 'isAuthenticated' , false ) ;
265+ setApiKey ( configuration , undefined ) ;
266+ ggshieldViewProvider . refresh ( ) ;
267+ ggshieldRemediationMessageViewProvider . refresh ( ) ;
268+ ggshieldQuotaViewProvider . refresh ( ) ;
258269 } )
259270 ) ;
260271 } )
Original file line number Diff line number Diff line change @@ -251,6 +251,12 @@ export async function loginGGShield(
251251 } ) ;
252252}
253253
254+ export function logoutGGShield (
255+ configuration : GGShieldConfiguration
256+ ) : void {
257+ const proc = runGGShieldCommand ( configuration , [ "auth" , "logout" ] ) ;
258+ }
259+
254260export function ggshieldAuthStatus (
255261 configuration : GGShieldConfiguration
256262) : boolean {
Original file line number Diff line number Diff line change @@ -40,10 +40,6 @@ export function getConfiguration(
4040
4141export function setApiKey ( configuration : GGShieldConfiguration , apiKey : string | undefined ) : void {
4242 const config = workspace . getConfiguration ( "gitguardian" ) ;
43- if ( ! apiKey ) {
44- throw new Error ( "Missing API Key" ) ;
45- }
46-
47- configuration . apiKey = apiKey ;
43+ configuration . apiKey = apiKey ? apiKey : "" ;
4844 config . update ( "apiKey" , apiKey , ConfigurationTarget . Global ) ;
4945}
You can’t perform that action at this time.
0 commit comments