Skip to content

Commit

Permalink
fixed cache clear login crash
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed Jul 12, 2024
1 parent 3fd20bc commit 6056e59
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 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
21 changes: 19 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,29 @@ 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)

println("Account.createAccount == $id")

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)

// Filter accounts with the same ID
val removeOtherAccounts = accounts.filter { it.name != id }

if (removeOtherAccounts.isNotEmpty()) {
// If there are duplicates, remove all but one
removeOtherAccounts.forEach { account ->
accountManager.removeAccountExplicitly(account)
}
}
accountManager.addAccountExplicitly(acc, KEY_PASSWORD, b)
}

fun update(context: Context, id: String, authState: String) {
Expand Down
3 changes: 2 additions & 1 deletion auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ dependencies {

implementation libs.kotlin.stdlib

api libs.alfresco.auth
// api libs.alfresco.auth
api project(":alfresco-auth")

implementation libs.google.material

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

buildscript {
repositories {
google()
Expand All @@ -6,12 +7,14 @@ buildscript {
dependencies {
classpath libs.android.gradle
classpath libs.kotlin.gradle
classpath libs.kotlin.serialization.plugin

classpath libs.objectbox

classpath libs.google.services.gradle
classpath libs.firebase.crashlytics.gradle

classpath libs.dokka
classpath libs.spotless
classpath libs.gradleVersionsPlugin
classpath libs.gradleLicensePlugin
Expand Down
3 changes: 2 additions & 1 deletion data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ dependencies {
api project(':session')
implementation project(':download')

implementation libs.alfresco.auth
// implementation libs.alfresco.auth
implementation project(":alfresco-auth")

implementation libs.alfresco.content
implementation libs.alfresco.contentKtx
Expand Down
21 changes: 17 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[versions]
camera = "1.2.3"
coil = "2.4.0"
Expand All @@ -12,12 +13,11 @@ test = "1.5.0"
activity-compose = "1.7.0"
compose-bom = "2023.10.01"
ui-tooling = "1.5.4"
appcompat = "1.6.1"
material = "1.11.0"
constraintlayout = "2.1.4"
auth0 = "2.10.2"

[libraries]
alfresco-auth = "com.alfresco.android:auth:0.8.2-SNAPSHOT"
#alfresco-auth = "com.alfresco.android:auth:0.8.1-SNAPSHOT"
alfresco-content = "com.alfresco.android:content:0.3.4-SNAPSHOT"
alfresco-contentKtx = "com.alfresco.android:content-ktx:0.3.2-SNAPSHOT"
alfresco-process = "com.alfresco.android:process:0.1.3-SNAPSHOT"
Expand Down Expand Up @@ -136,4 +136,17 @@ ui-compose-viewbinding = "androidx.compose.ui:ui-viewbinding:1.6.3"
navigation-compose = "androidx.navigation:navigation-compose:2.7.6"
compose-runtime = "androidx.compose.runtime:runtime:1.5.4"
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "ui-tooling" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }

kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
kotlin-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.8.10"

appauth = "net.openid:appauth:0.11.1"

auth0 = { module = "com.auth0.android:auth0", version.ref = "auth0" }

jwtdecode = "com.auth0.android:jwtdecode:2.0.2"
androidx-lifecycle-viewmodelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
androidx-browser = "androidx.browser:browser:1.5.0"
okhttp = "com.squareup.okhttp3:okhttp:4.11.0"
3 changes: 2 additions & 1 deletion session/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dependencies {
implementation project(':base')
api project(':account')

implementation libs.alfresco.auth
// implementation libs.alfresco.auth
implementation project(":alfresco-auth")
implementation libs.alfresco.content

implementation libs.kotlin.stdlib
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ include ':move'
include ':component'
include ':app'
include ':process-app'
include ':alfresco-auth'

0 comments on commit 6056e59

Please sign in to comment.