From 2d6c886317c8559599f0d471e05ea8fa6a6fb6fa Mon Sep 17 00:00:00 2001
From: Tamara Steinwender <tamara.steinwender@tugraz.at>
Date: Mon, 22 Nov 2021 15:57:43 +0100
Subject: [PATCH] Remove local storage nextcloud vars on fail

---
 packages/file-handling/src/nextcloud-file-picker.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js
index 9b108fb2..3daa45dc 100644
--- a/packages/file-handling/src/nextcloud-file-picker.js
+++ b/packages/file-handling/src/nextcloud-file-picker.js
@@ -417,16 +417,22 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
     }
 
 
-
     /**
      *
      */
     async checkLocalStorage() {
-        if (!this.isLoggedIn() || !this.auth)
+        if (!this.isLoggedIn() || !this.auth) {
+            for (let [key, value] of Object.entries(localStorage)) {
+                if (key.includes("nextcloud-webdav-username-") || key.includes("nextcloud-webdav-password-")) {
+                    localStorage.removeItem(key);
+                }
+            }
             return;
+        }
         const publicId = this.auth['person-id'];
         const token = parseJwt(this.auth.token);
         const sessionId = token ? token.sid : "";
+
         if (this.storeSession && sessionId
             && localStorage.getItem('nextcloud-webdav-username-' + publicId)
             && localStorage.getItem('nextcloud-webdav-password-' + publicId) ){
@@ -451,6 +457,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
         }
     }
 
+
     /**
      * check mime type of row
      *
-- 
GitLab