From 04e68ca5e55a926cd268b3374312a46bf30d7114 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:49:53 +0530 Subject: [PATCH] fixed login issue (#367) --- .../com/alfresco/auth/activity/LoginViewModel.kt | 13 +++++++++++++ .../alfresco/content/data/OfflineRepository.kt | 16 +++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/auth/src/main/kotlin/com/alfresco/auth/activity/LoginViewModel.kt b/auth/src/main/kotlin/com/alfresco/auth/activity/LoginViewModel.kt index 4902e763..2e3f1063 100644 --- a/auth/src/main/kotlin/com/alfresco/auth/activity/LoginViewModel.kt +++ b/auth/src/main/kotlin/com/alfresco/auth/activity/LoginViewModel.kt @@ -141,6 +141,19 @@ class LoginViewModel( additionalParams = additionalParams, ) } + + oAuth2Data != null && (oAuth2Data.authType.isNullOrEmpty() || oAuth2Data.authType?.lowercase() == IdentityProvider.KEYCLOAK.value()) -> { + authConfig = + AuthConfig( + https = authConfig.https, + port = authConfig.port, + contentServicePath = authConfig.contentServicePath, + realm = authConfig.realm, + clientId = authConfig.clientId, + redirectUrl = authConfig.redirectUrl, + scope = oAuth2Data.scope, + ) + } } when (authType) { diff --git a/data/src/main/kotlin/com/alfresco/content/data/OfflineRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/OfflineRepository.kt index f4d0d04c..1c8d99bb 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/OfflineRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/OfflineRepository.kt @@ -6,7 +6,6 @@ import android.provider.MediaStore import com.alfresco.content.session.ActionSessionInvalid import com.alfresco.content.session.Session import com.alfresco.content.session.SessionManager -import com.alfresco.content.session.SessionNotFoundException import com.alfresco.events.EventBus import io.objectbox.Box import io.objectbox.BoxStore @@ -24,16 +23,22 @@ import java.io.File class OfflineRepository(otherSession: Session? = null) { lateinit var session: Session private val coroutineScope = CoroutineScope(Dispatchers.Main) + private var box: Box init { try { session = otherSession ?: SessionManager.requireSession - } catch (e: SessionNotFoundException) { + ObjectBox.init(session.context) + box = ObjectBox.boxStore.boxFor() + } catch (e: Exception) { e.printStackTrace() coroutineScope.launch { EventBus.default.send(ActionSessionInvalid(true)) } } + + ObjectBox.init(session.context) + box = ObjectBox.boxStore.boxFor() } private object ObjectBox { @@ -49,13 +54,6 @@ class OfflineRepository(otherSession: Session? = null) { } } - private val box: Box - - init { - ObjectBox.init(session.context) - box = ObjectBox.boxStore.boxFor() - } - fun entry(id: String): Entry? = box.query() .equal(Entry_.id, id, StringOrder.CASE_SENSITIVE)