Ensure user cannot select unsupported homeserver. In this case show the appropriate error (parity with iOS)
This commit is contained in:
parent
8fa2c6c85f
commit
e3ed75d19e
4 changed files with 45 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.element.android.features.login.impl.R
|
||||
import io.element.android.features.login.impl.accesscontrol.DefaultAccountProviderAccessControl
|
||||
import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
||||
|
|
@ -60,7 +61,13 @@ class ChangeServerPresenter(
|
|||
title = data.title,
|
||||
accountProviderUrl = data.url,
|
||||
)
|
||||
authenticationService.setHomeserver(data.url).getOrThrow()
|
||||
val details = authenticationService.setHomeserver(data.url).getOrThrow()
|
||||
if (details.supportsOidcLogin.not() && details.supportsPasswordLogin.not()) {
|
||||
// Unsupported homeserver
|
||||
throw ChangeServerError.Error(
|
||||
messageId = R.string.screen_login_error_unsupported_authentication,
|
||||
)
|
||||
}
|
||||
// Homeserver is valid, remember user choice
|
||||
accountProviderDataSource.userSelection(data)
|
||||
}.runCatchingUpdatingState(changeServerAction, errorTransform = ChangeServerError::from)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
package io.element.android.features.login.impl.changeserver
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.login.impl.R
|
||||
import io.element.android.features.login.impl.error.ChangeServerError
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
|
@ -34,6 +35,13 @@ open class ChangeServerStateProvider : PreviewParameterProvider<ChangeServerStat
|
|||
),
|
||||
)
|
||||
),
|
||||
aChangeServerState(
|
||||
changeServerAction = AsyncData.Failure(
|
||||
ChangeServerError.Error(
|
||||
R.string.screen_login_error_unsupported_authentication
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ sealed class ChangeServerError : Exception() {
|
|||
|
||||
companion object {
|
||||
fun from(error: Throwable): ChangeServerError = when (error) {
|
||||
is ChangeServerError -> error
|
||||
is AuthenticationException.SlidingSyncVersion -> SlidingSyncAlert
|
||||
is AuthenticationException.Oidc -> Error(messageStr = error.message)
|
||||
is AccountProviderAccessException.NeedElementProException -> NeedElementPro(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue