Browse Source

AccountRemovalWork: remove cached owncloudClient after removing account

Otherwise, the account (which is identified by account name only) will reuse old token, if login is done right after account removal.

Three hours of debugging for one line of code

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 years ago
parent
commit
95046c4b5d
1 changed files with 3 additions and 1 deletions
  1. 3 1
      app/src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt

+ 3 - 1
app/src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt

@@ -58,7 +58,6 @@ import com.owncloud.android.utils.FileStorageUtils
 import com.owncloud.android.utils.PushUtils
 import org.greenrobot.eventbus.EventBus
 import java.io.File
-import java.util.ArrayList
 
 /**
  * Removes account and all local files
@@ -150,6 +149,9 @@ class AccountRemovalWork(
             deleteAppPasswordRemoteOperation.execute(optionNextcloudClient.get())
         }
 
+        // delete cached OwncloudClient
+        OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(user.toOwnCloudAccount())
+
         if (userRemoved) {
             eventBus.post(AccountRemovedEvent())
         }