Skip to content

Commit

Permalink
ADST-528 (#353)
Browse files Browse the repository at this point in the history
* fixed cache clear login crash
  • Loading branch information
aman-alfresco authored Jul 12, 2024
1 parent 3fd20bc commit ebcd8d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ app/google-services_2.json
/build-other.gradle
/gradle/libs.versions-other.toml
/alfresco-auth/
/build-app.gradle
/gradle/libs.versions-app.toml
17 changes: 15 additions & 2 deletions account/src/main/kotlin/com/alfresco/content/account/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,25 @@ data class Account(
b.putString(myFilesKey, myFiles)
b.putString(hostNameKey, hostName)
b.putString(clientIdKey, clientId)
val acc = AndroidAccount(id, context.getString(R.string.android_auth_account_type))

val accountType = context.getString(R.string.android_auth_account_type)

val acc = AndroidAccount(id, accountType)

// Save credentials securely using the SecureSharedPreferencesManager
sharedSecure.saveCredentials(email, authState, displayName, hostName, clientId)

AccountManager.get(context).addAccountExplicitly(acc, KEY_PASSWORD, b)
val accountManager = AccountManager.get(context)
val accounts = accountManager.getAccountsByType(accountType)

val removeOtherAccounts = accounts.filter { it.name != id }

if (removeOtherAccounts.isNotEmpty()) {
removeOtherAccounts.forEach { account ->
accountManager.removeAccountExplicitly(account)
}
}
accountManager.addAccountExplicitly(acc, KEY_PASSWORD, b)
}

fun update(context: Context, id: String, authState: String) {
Expand Down

0 comments on commit ebcd8d2

Please sign in to comment.