SoftLogout: also handle Unsupported mode

This commit is contained in:
Benoit Marty 2019-12-13 12:08:37 +01:00
parent 1de85daad9
commit 12d54140e5
3 changed files with 24 additions and 15 deletions

View File

@ -110,18 +110,24 @@ class SoftLogoutController @Inject constructor(
errorText((state.asyncLoginAction as? Fail)?.error?.let { errorFormatter.toHumanReadable(it) })
passwordRevealClickListener { listener?.revealPasswordClicked() }
forgetPasswordClickListener { listener?.forgetPasswordClicked() }
submitClickListener { password -> listener?.submit(password) }
submitClickListener { password -> listener?.signinSubmit(password) }
}
}
LoginMode.Sso -> {
loginCenterButtonItem {
id("sso")
text(stringProvider.getString(R.string.login_signin_sso))
listener { listener?.ssoSubmit() }
listener { listener?.signinFallbackSubmit() }
}
}
LoginMode.Unsupported -> {
loginCenterButtonItem {
id("fallback")
text(stringProvider.getString(R.string.login_signin))
listener { listener?.signinFallbackSubmit() }
}
}
LoginMode.Unknown -> Unit // Should not happen
LoginMode.Unsupported -> Unit // Should not happen
}
}
}
@ -146,8 +152,8 @@ class SoftLogoutController @Inject constructor(
interface Listener {
fun retry()
fun passwordEdited(password: String)
fun submit(password: String)
fun ssoSubmit()
fun signinSubmit(password: String)
fun signinFallbackSubmit()
fun clearData()
fun forgetPasswordClicked()
fun revealPasswordClicked()

View File

@ -59,12 +59,16 @@ class SoftLogoutFragment @Inject constructor(
softLogoutViewModel.subscribe(this) { softLogoutViewState ->
softLogoutController.update(softLogoutViewState)
if (softLogoutViewState.asyncHomeServerLoginFlowRequest.invoke() == LoginMode.Sso) {
// Prepare the loginViewModel for a SSO recovery
loginViewModel.handle(LoginAction.SetupSsoForSessionRecovery(
softLogoutViewState.homeServerUrl,
softLogoutViewState.deviceId
))
when (softLogoutViewState.asyncHomeServerLoginFlowRequest.invoke()) {
LoginMode.Sso,
LoginMode.Unsupported -> {
// Prepare the loginViewModel for a SSO/login fallback recovery
loginViewModel.handle(LoginAction.SetupSsoForSessionRecovery(
softLogoutViewState.homeServerUrl,
softLogoutViewState.deviceId
))
}
else -> Unit
}
}
}
@ -88,12 +92,12 @@ class SoftLogoutFragment @Inject constructor(
softLogoutViewModel.handle(SoftLogoutAction.PasswordChanged(password))
}
override fun submit(password: String) {
override fun signinSubmit(password: String) {
cleanupUi()
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(password))
}
override fun ssoSubmit() {
override fun signinFallbackSubmit() {
loginSharedActionViewModel.post(LoginNavigation.OnSignModeSelected)
}

View File

@ -111,8 +111,7 @@ class SoftLogoutViewModel @AssistedInject constructor(
else -> LoginMode.Unsupported
}
if ((loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported)
|| loginMode == LoginMode.Unsupported) {
if (loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported) {
notSupported()
} else {
setState {