Skip to content

Commit

Permalink
fixed login issue (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco authored Dec 17, 2024
1 parent 8d532ea commit 04e68ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
13 changes: 13 additions & 0 deletions auth/src/main/kotlin/com/alfresco/auth/activity/LoginViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Entry>

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 {
Expand All @@ -49,13 +54,6 @@ class OfflineRepository(otherSession: Session? = null) {
}
}

private val box: Box<Entry>

init {
ObjectBox.init(session.context)
box = ObjectBox.boxStore.boxFor()
}

fun entry(id: String): Entry? =
box.query()
.equal(Entry_.id, id, StringOrder.CASE_SENSITIVE)
Expand Down

0 comments on commit 04e68ca

Please sign in to comment.