Allow using an outdated homeserver, at user's risk (#1972)
Just warn the user using a non blocking popup
This commit is contained in:
parent
cede7b1dc1
commit
8edecf5937
|
@ -9,6 +9,7 @@ Improvements 🙌:
|
||||||
- Visually disable call buttons in menu and prohibit calling when permissions are insufficient (#2112)
|
- Visually disable call buttons in menu and prohibit calling when permissions are insufficient (#2112)
|
||||||
- Add a setting to show timestamp for all messages (#2123)
|
- Add a setting to show timestamp for all messages (#2123)
|
||||||
- Use cache for user color
|
- Use cache for user color
|
||||||
|
- Allow using an outdated homeserver, at user's risk (#1972)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Long message cannot be sent/takes infinite time & blocks other messages #1397
|
- Long message cannot be sent/takes infinite time & blocks other messages #1397
|
||||||
|
|
|
@ -17,13 +17,11 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.auth.data
|
package org.matrix.android.sdk.api.auth.data
|
||||||
|
|
||||||
// Either a list of supported login types, or an error if the homeserver is outdated
|
|
||||||
sealed class LoginFlowResult {
|
sealed class LoginFlowResult {
|
||||||
data class Success(
|
data class Success(
|
||||||
val supportedLoginTypes: List<String>,
|
val supportedLoginTypes: List<String>,
|
||||||
val isLoginAndRegistrationSupported: Boolean,
|
val isLoginAndRegistrationSupported: Boolean,
|
||||||
val homeServerUrl: String
|
val homeServerUrl: String,
|
||||||
|
val isOutdatedHomeserver: Boolean
|
||||||
) : LoginFlowResult()
|
) : LoginFlowResult()
|
||||||
|
|
||||||
object OutdatedHomeserver : LoginFlowResult()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,16 +273,16 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getLoginFlowResult(authAPI: AuthAPI, versions: Versions, homeServerUrl: String): LoginFlowResult {
|
private suspend fun getLoginFlowResult(authAPI: AuthAPI, versions: Versions, homeServerUrl: String): LoginFlowResult {
|
||||||
return if (versions.isSupportedBySdk()) {
|
|
||||||
// Get the login flow
|
// Get the login flow
|
||||||
val loginFlowResponse = executeRequest<LoginFlowResponse>(null) {
|
val loginFlowResponse = executeRequest<LoginFlowResponse>(null) {
|
||||||
apiCall = authAPI.getLoginFlows()
|
apiCall = authAPI.getLoginFlows()
|
||||||
}
|
}
|
||||||
LoginFlowResult.Success(loginFlowResponse.flows.orEmpty().mapNotNull { it.type }, versions.isLoginAndRegistrationSupportedBySdk(), homeServerUrl)
|
return LoginFlowResult.Success(
|
||||||
} else {
|
loginFlowResponse.flows.orEmpty().mapNotNull { it.type },
|
||||||
// Not supported
|
versions.isLoginAndRegistrationSupportedBySdk(),
|
||||||
LoginFlowResult.OutdatedHomeserver
|
homeServerUrl,
|
||||||
}
|
!versions.isSupportedBySdk()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRegistrationWizard(): RegistrationWizard {
|
override fun getRegistrationWizard(): RegistrationWizard {
|
||||||
|
|
|
@ -42,10 +42,10 @@ import im.vector.app.features.login.terms.LoginTermsFragment
|
||||||
import im.vector.app.features.login.terms.LoginTermsFragmentArgument
|
import im.vector.app.features.login.terms.LoginTermsFragmentArgument
|
||||||
import im.vector.app.features.login.terms.toLocalizedLoginTerms
|
import im.vector.app.features.login.terms.toLocalizedLoginTerms
|
||||||
import im.vector.app.features.pin.UnlockedActivity
|
import im.vector.app.features.pin.UnlockedActivity
|
||||||
|
import kotlinx.android.synthetic.main.activity_login.*
|
||||||
import org.matrix.android.sdk.api.auth.registration.FlowResult
|
import org.matrix.android.sdk.api.auth.registration.FlowResult
|
||||||
import org.matrix.android.sdk.api.auth.registration.Stage
|
import org.matrix.android.sdk.api.auth.registration.Stage
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import kotlinx.android.synthetic.main.activity_login.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarConfigurable, UnlockedAc
|
||||||
is LoginViewEvents.OutdatedHomeserver -> {
|
is LoginViewEvents.OutdatedHomeserver -> {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.login_error_outdated_homeserver_title)
|
.setTitle(R.string.login_error_outdated_homeserver_title)
|
||||||
.setMessage(R.string.login_error_outdated_homeserver_content)
|
.setMessage(R.string.login_error_outdated_homeserver_warning_content)
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.show()
|
.show()
|
||||||
Unit
|
Unit
|
||||||
|
|
|
@ -748,9 +748,6 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported) {
|
|
||||||
notSupported()
|
|
||||||
} else {
|
|
||||||
// FIXME We should post a view event here normally?
|
// FIXME We should post a view event here normally?
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
@ -760,22 +757,12 @@ class LoginViewModel @AssistedInject constructor(
|
||||||
loginModeSupportedTypes = data.supportedLoginTypes.toList()
|
loginModeSupportedTypes = data.supportedLoginTypes.toList()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
if ((loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported)
|
||||||
}
|
|| data.isOutdatedHomeserver) {
|
||||||
is LoginFlowResult.OutdatedHomeserver -> {
|
|
||||||
notSupported()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun notSupported() {
|
|
||||||
// Notify the UI
|
// Notify the UI
|
||||||
_viewEvents.post(LoginViewEvents.OutdatedHomeserver)
|
_viewEvents.post(LoginViewEvents.OutdatedHomeserver)
|
||||||
|
}
|
||||||
setState {
|
}
|
||||||
copy(
|
|
||||||
asyncHomeServerLoginFlowRequest = Uninitialized
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,16 +25,16 @@ import com.airbnb.mvrx.Uninitialized
|
||||||
import com.airbnb.mvrx.ViewModelContext
|
import com.airbnb.mvrx.ViewModelContext
|
||||||
import com.squareup.inject.assisted.Assisted
|
import com.squareup.inject.assisted.Assisted
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
|
import im.vector.app.core.extensions.hasUnsavedKeys
|
||||||
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
|
import im.vector.app.features.login.LoginMode
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||||
import org.matrix.android.sdk.api.auth.data.LoginFlowResult
|
import org.matrix.android.sdk.api.auth.data.LoginFlowResult
|
||||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.util.Cancelable
|
import org.matrix.android.sdk.api.util.Cancelable
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
|
||||||
import im.vector.app.core.extensions.hasUnsavedKeys
|
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
|
||||||
import im.vector.app.features.login.LoginMode
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,9 +110,6 @@ class SoftLogoutViewModel @AssistedInject constructor(
|
||||||
else -> LoginMode.Unsupported
|
else -> LoginMode.Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported) {
|
|
||||||
notSupported()
|
|
||||||
} else {
|
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
asyncHomeServerLoginFlowRequest = Success(loginMode)
|
asyncHomeServerLoginFlowRequest = Success(loginMode)
|
||||||
|
@ -120,20 +117,6 @@ class SoftLogoutViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is LoginFlowResult.OutdatedHomeserver -> {
|
|
||||||
notSupported()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun notSupported() {
|
|
||||||
// Should not happen since it's a re-logout
|
|
||||||
// Notify the UI
|
|
||||||
setState {
|
|
||||||
copy(
|
|
||||||
asyncHomeServerLoginFlowRequest = Fail(IllegalStateException("Should not happen"))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1988,6 +1988,7 @@
|
||||||
<string name="login_validation_code_is_not_correct">The entered code is not correct. Please check.</string>
|
<string name="login_validation_code_is_not_correct">The entered code is not correct. Please check.</string>
|
||||||
<string name="login_error_outdated_homeserver_title">Outdated homeserver</string>
|
<string name="login_error_outdated_homeserver_title">Outdated homeserver</string>
|
||||||
<string name="login_error_outdated_homeserver_content">This homeserver is running too old a version to connect to. Ask your homeserver admin to upgrade.</string>
|
<string name="login_error_outdated_homeserver_content">This homeserver is running too old a version to connect to. Ask your homeserver admin to upgrade.</string>
|
||||||
|
<string name="login_error_outdated_homeserver_warning_content">This homeserver is running an old version. Ask your homeserver admin to upgrade. You can continue, but some features may not work correctly.</string>
|
||||||
|
|
||||||
<plurals name="login_error_limit_exceeded_retry_after">
|
<plurals name="login_error_limit_exceeded_retry_after">
|
||||||
<item quantity="one">Too many requests have been sent. You can retry in %1$d second…</item>
|
<item quantity="one">Too many requests have been sent. You can retry in %1$d second…</item>
|
||||||
|
|
Loading…
Reference in New Issue