]> git.lizzy.rs Git - rust.git/commitdiff
Fix clearing the token
authorMatthias Einwag <matthias.einwag@live.com>
Wed, 23 Sep 2020 08:03:34 +0000 (01:03 -0700)
committerMatthias Einwag <matthias.einwag@live.com>
Wed, 23 Sep 2020 08:03:34 +0000 (01:03 -0700)
The previous version would have interpreted an empty token as
an abort of the dialog and would have not properly cleared the token.
This is now fixed by checking for `undefined` for a an abort and
by setting the token to `undefined` in order to clear it.

editors/code/src/main.ts

index 2fcd853d444a8b77d9b92101ed6a20f87bb5a61c..ce7c56d05a8e9507d23651e9482536b0355930a9 100644 (file)
@@ -393,8 +393,13 @@ async function queryForGithubToken(state: PersistentState): Promise<void> {
     };
 
     const newToken = await vscode.window.showInputBox(githubTokenOptions);
-    if (newToken) {
-        log.info("Storing new github token");
-        await state.updateGithubToken(newToken);
+    if (newToken !== undefined) {
+        if (newToken === "") {
+            log.info("Clearing github token");
+            await state.updateGithubToken(undefined);
+        } else {
+            log.info("Storing new github token");
+            await state.updateGithubToken(newToken);
+        }
     }
 }