Some cleanup

This commit is contained in:
Benoit Marty 2021-02-03 14:52:58 +01:00
parent e976100f1a
commit ad9873c565
6 changed files with 47 additions and 44 deletions

View file

@ -245,7 +245,7 @@ interface Session :
val sharedSecretStorageService: SharedSecretStorageService val sharedSecretStorageService: SharedSecretStorageService
fun getUIASsoFallbackUrl(authenticationSessionId: String): String fun getUiaSsoFallbackUrl(authenticationSessionId: String): String
/** /**
* Maintenance API, allows to print outs info on DB size to logcat * Maintenance API, allows to print outs info on DB size to logcat

View file

@ -36,3 +36,6 @@ internal const val SSO_REDIRECT_PATH = "/_matrix/client/r0/login/sso/redirect"
internal const val MSC2858_SSO_REDIRECT_PATH = "/_matrix/client/unstable/org.matrix.msc2858/login/sso/redirect" internal const val MSC2858_SSO_REDIRECT_PATH = "/_matrix/client/unstable/org.matrix.msc2858/login/sso/redirect"
internal const val SSO_REDIRECT_URL_PARAM = "redirectUrl" internal const val SSO_REDIRECT_URL_PARAM = "redirectUrl"
// Ref: https://matrix.org/docs/spec/client_server/r0.6.1#single-sign-on
internal const val SSO_UIA_FALLBACK_PATH = "/_matrix/client/r0/auth/m.login.sso/fallback/web"

View file

@ -52,6 +52,8 @@ import org.matrix.android.sdk.api.session.terms.TermsService
import org.matrix.android.sdk.api.session.typing.TypingUsersTracker import org.matrix.android.sdk.api.session.typing.TypingUsersTracker
import org.matrix.android.sdk.api.session.user.UserService import org.matrix.android.sdk.api.session.user.UserService
import org.matrix.android.sdk.api.session.widgets.WidgetService import org.matrix.android.sdk.api.session.widgets.WidgetService
import org.matrix.android.sdk.api.util.appendParamToUrl
import org.matrix.android.sdk.internal.auth.SSO_UIA_FALLBACK_PATH
import org.matrix.android.sdk.internal.auth.SessionParamsStore import org.matrix.android.sdk.internal.auth.SessionParamsStore
import org.matrix.android.sdk.internal.crypto.DefaultCryptoService import org.matrix.android.sdk.internal.crypto.DefaultCryptoService
import org.matrix.android.sdk.internal.database.tools.RealmDebugTools import org.matrix.android.sdk.internal.database.tools.RealmDebugTools
@ -273,16 +275,15 @@ internal class DefaultSession @Inject constructor(
return "$myUserId - ${sessionParams.deviceId}" return "$myUserId - ${sessionParams.deviceId}"
} }
override fun getUIASsoFallbackUrl(authenticationSessionId: String): String { override fun getUiaSsoFallbackUrl(authenticationSessionId: String): String {
val hsBas = sessionParams.homeServerConnectionConfig val hsBas = sessionParams.homeServerConnectionConfig
.homeServerUri .homeServerUri
.toString() .toString()
.trim { it == '/' } .trim { it == '/' }
return buildString { return buildString {
append(hsBas) append(hsBas)
append("/_matrix/client/r0/auth/m.login.sso/fallback/web") append(SSO_UIA_FALLBACK_PATH)
append("?session=") appendParamToUrl("session", authenticationSessionId)
append(authenticationSessionId)
} }
} }

View file

@ -55,7 +55,7 @@ class ReAuthViewModel @AssistedInject constructor(
ReAuthActions.StartSSOFallback -> { ReAuthActions.StartSSOFallback -> {
if (state.flowType == LoginFlowTypes.SSO) { if (state.flowType == LoginFlowTypes.SSO) {
setState { copy(ssoFallbackPageWasShown = true) } setState { copy(ssoFallbackPageWasShown = true) }
val ssoURL = session.getUIASsoFallbackUrl(initialState.session ?: "") val ssoURL = session.getUiaSsoFallbackUrl(initialState.session ?: "")
_viewEvents.post(ReAuthEvents.OpenSsoURl(ssoURL)) _viewEvents.post(ReAuthEvents.OpenSsoURl(ssoURL))
} }
} }

View file

@ -70,13 +70,12 @@ class BootstrapReAuthFragment @Inject constructor(
return@withState return@withState
} }
val failure = state.step.failure val failure = state.step.failure
views.reAuthFailureText.setTextOrHide(failure)
if (failure == null) { if (failure == null) {
views.reAuthFailureText.setTextOrHide(null)
views.waitingProgress.isVisible = true views.waitingProgress.isVisible = true
views.bootstrapCancelButton.isVisible = false views.bootstrapCancelButton.isVisible = false
views.bootstrapRetryButton.isVisible = false views.bootstrapRetryButton.isVisible = false
} else { } else {
views.reAuthFailureText.setTextOrHide(failure)
views.waitingProgress.isVisible = false views.waitingProgress.isVisible = false
views.bootstrapCancelButton.isVisible = true views.bootstrapCancelButton.isVisible = true
views.bootstrapRetryButton.isVisible = true views.bootstrapRetryButton.isVisible = true