Fix issue of QR not being offered where domain is entered instead of homeserver
This commit is contained in:
parent
c523e144b8
commit
1930047ce1
|
@ -125,12 +125,6 @@ interface AuthenticationService {
|
|||
deviceId: String? = null
|
||||
): Session
|
||||
|
||||
/**
|
||||
* @param homeServerConnectionConfig the information about the homeserver and other configuration
|
||||
* Return true if qr code login is supported by the server, false otherwise.
|
||||
*/
|
||||
suspend fun isQrLoginSupported(homeServerConnectionConfig: HomeServerConnectionConfig): Boolean
|
||||
|
||||
/**
|
||||
* Authenticate using m.login.token method during sign in with QR code.
|
||||
* @param homeServerConnectionConfig the information about the homeserver and other configuration
|
||||
|
|
|
@ -22,5 +22,6 @@ data class LoginFlowResult(
|
|||
val isLoginAndRegistrationSupported: Boolean,
|
||||
val homeServerUrl: String,
|
||||
val isOutdatedHomeserver: Boolean,
|
||||
val isLogoutDevicesSupported: Boolean
|
||||
val isLogoutDevicesSupported: Boolean,
|
||||
val isLoginWithQrSupported: Boolean,
|
||||
)
|
||||
|
|
|
@ -299,7 +299,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
isLoginAndRegistrationSupported = versions.isLoginAndRegistrationSupportedBySdk(),
|
||||
homeServerUrl = homeServerUrl,
|
||||
isOutdatedHomeserver = !versions.isSupportedBySdk(),
|
||||
isLogoutDevicesSupported = versions.doesServerSupportLogoutDevices()
|
||||
isLogoutDevicesSupported = versions.doesServerSupportLogoutDevices(),
|
||||
isLoginWithQrSupported = versions.doesServerSupportQrCodeLogin(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -408,20 +409,6 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
override suspend fun isQrLoginSupported(homeServerConnectionConfig: HomeServerConnectionConfig): Boolean {
|
||||
val authAPI = buildAuthAPI(homeServerConnectionConfig)
|
||||
val versions = runCatching {
|
||||
executeRequest(null) {
|
||||
authAPI.versions()
|
||||
}
|
||||
}
|
||||
return if (versions.isSuccess) {
|
||||
versions.getOrNull()?.doesServerSupportQrCodeLogin().orFalse()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun loginUsingQrLoginToken(
|
||||
homeServerConnectionConfig: HomeServerConnectionConfig,
|
||||
loginToken: String,
|
||||
|
|
|
@ -118,7 +118,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun checkQrCodeLoginCapability(config: HomeServerConnectionConfig) {
|
||||
private fun checkQrCodeLoginCapability() {
|
||||
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
||||
setState {
|
||||
copy(
|
||||
|
@ -133,11 +133,9 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
} else {
|
||||
// check if selected server supports MSC3882 first
|
||||
val canLoginWithQrCode = authenticationService.isQrLoginSupported(config)
|
||||
setState {
|
||||
copy(
|
||||
canLoginWithQrCode = canLoginWithQrCode
|
||||
canLoginWithQrCode = selectedHomeserver.isLoginWithQrSupported
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +703,10 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
// This is invalid
|
||||
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
||||
} else {
|
||||
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
||||
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, suspend {
|
||||
checkQrCodeLoginCapability()
|
||||
postAction()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ data class SelectedHomeserverState(
|
|||
val preferredLoginMode: LoginMode = LoginMode.Unknown,
|
||||
val supportedLoginTypes: List<String> = emptyList(),
|
||||
val isLogoutDevicesSupported: Boolean = false,
|
||||
val isLoginWithQrSupported: Boolean = false,
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
|
|
|
@ -47,7 +47,8 @@ class StartAuthenticationFlowUseCase @Inject constructor(
|
|||
upstreamUrl = authFlow.homeServerUrl,
|
||||
preferredLoginMode = preferredLoginMode,
|
||||
supportedLoginTypes = authFlow.supportedLoginTypes,
|
||||
isLogoutDevicesSupported = authFlow.isLogoutDevicesSupported
|
||||
isLogoutDevicesSupported = authFlow.isLogoutDevicesSupported,
|
||||
isLoginWithQrSupported = authFlow.isLoginWithQrSupported,
|
||||
)
|
||||
|
||||
private fun LoginFlowResult.findPreferredLoginMode() = when {
|
||||
|
|
Loading…
Reference in New Issue