mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 12:00:03 +03:00
chaining the current authentication type into the onboarding state
This commit is contained in:
parent
e89f9eae1a
commit
ac89495348
6 changed files with 19 additions and 8 deletions
|
@ -54,6 +54,7 @@ import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||||
import org.matrix.android.sdk.api.auth.HomeServerHistoryService
|
import org.matrix.android.sdk.api.auth.HomeServerHistoryService
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
|
import org.matrix.android.sdk.api.auth.data.SsoIdentityProvider
|
||||||
import org.matrix.android.sdk.api.auth.login.LoginWizard
|
import org.matrix.android.sdk.api.auth.login.LoginWizard
|
||||||
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.RegistrationWizard
|
import org.matrix.android.sdk.api.auth.registration.RegistrationWizard
|
||||||
|
@ -292,7 +293,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
is RegistrationResult.Complete -> onSessionCreated(
|
is RegistrationResult.Complete -> onSessionCreated(
|
||||||
it.session,
|
it.session,
|
||||||
authenticationDescription = AuthenticationDescription.AccountCreated(
|
authenticationDescription = AuthenticationDescription.AccountCreated(
|
||||||
AuthenticationDescription.AuthenticationType.Password
|
awaitState().selectedAuthenticationState.type ?: AuthenticationDescription.AuthenticationType.Other
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
is RegistrationResult.NextStep -> onFlowResponse(it.flowResult, onNextRegistrationStepAction)
|
is RegistrationResult.NextStep -> onFlowResponse(it.flowResult, onNextRegistrationStepAction)
|
||||||
|
@ -324,6 +325,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
private fun OnboardingViewState.hasSelectedMatrixOrg() = selectedHomeserver.userFacingUrl == matrixOrgUrl
|
private fun OnboardingViewState.hasSelectedMatrixOrg() = selectedHomeserver.userFacingUrl == matrixOrgUrl
|
||||||
|
|
||||||
private fun handleRegisterWith(action: AuthenticateAction.Register) {
|
private fun handleRegisterWith(action: AuthenticateAction.Register) {
|
||||||
|
setState { copy(selectedAuthenticationState = SelectedAuthenticationState(AuthenticationDescription.AuthenticationType.Password)) }
|
||||||
reAuthHelper.data = action.password
|
reAuthHelper.data = action.password
|
||||||
handleRegisterAction(
|
handleRegisterAction(
|
||||||
RegisterAction.CreateAccount(
|
RegisterAction.CreateAccount(
|
||||||
|
@ -750,8 +752,9 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
return loginConfig?.homeServerUrl
|
return loginConfig?.homeServerUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSsoUrl(redirectUrl: String, deviceId: String?, providerId: String?): String? {
|
fun getSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
|
||||||
return authenticationService.getSsoUrl(redirectUrl, deviceId, providerId)
|
setState { copy(selectedAuthenticationState = SelectedAuthenticationState(provider.toAuthenticationType())) }
|
||||||
|
return authenticationService.getSsoUrl(redirectUrl, deviceId, provider?.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFallbackUrl(forSignIn: Boolean, deviceId: String?): String? {
|
fun getFallbackUrl(forSignIn: Boolean, deviceId: String?): String? {
|
||||||
|
|
|
@ -51,6 +51,9 @@ data class OnboardingViewState(
|
||||||
@PersistState
|
@PersistState
|
||||||
val selectedHomeserver: SelectedHomeserverState = SelectedHomeserverState(),
|
val selectedHomeserver: SelectedHomeserverState = SelectedHomeserverState(),
|
||||||
|
|
||||||
|
@PersistState
|
||||||
|
val selectedAuthenticationState: SelectedAuthenticationState = SelectedAuthenticationState(),
|
||||||
|
|
||||||
@PersistState
|
@PersistState
|
||||||
val personalizationState: PersonalizationState = PersonalizationState()
|
val personalizationState: PersonalizationState = PersonalizationState()
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
@ -80,3 +83,8 @@ data class PersonalizationState(
|
||||||
|
|
||||||
fun supportsPersonalization() = supportsChangingDisplayName || supportsChangingProfilePicture
|
fun supportsPersonalization() = supportsChangingDisplayName || supportsChangingProfilePicture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class SelectedAuthenticationState(
|
||||||
|
val type: AuthenticationDescription.AuthenticationType? = null,
|
||||||
|
) : Parcelable
|
||||||
|
|
|
@ -93,7 +93,7 @@ abstract class AbstractSSOFtueAuthFragment<VB : ViewBinding> : AbstractFtueAuthF
|
||||||
viewModel.getSsoUrl(
|
viewModel.getSsoUrl(
|
||||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||||
deviceId = state.deviceId,
|
deviceId = state.deviceId,
|
||||||
providerId = null
|
provider = null
|
||||||
)
|
)
|
||||||
?.let { prefetchUrl(it) }
|
?.let { prefetchUrl(it) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
||||||
viewModel.getSsoUrl(
|
viewModel.getSsoUrl(
|
||||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||||
deviceId = deviceId,
|
deviceId = deviceId,
|
||||||
providerId = provider?.id
|
provider = provider
|
||||||
)?.let { openInCustomTab(it) }
|
)?.let { openInCustomTab(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ class FtueAuthLoginFragment @Inject constructor() : AbstractSSOFtueAuthFragment<
|
||||||
viewModel.getSsoUrl(
|
viewModel.getSsoUrl(
|
||||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||||
deviceId = state.deviceId,
|
deviceId = state.deviceId,
|
||||||
providerId = provider?.id
|
provider = provider
|
||||||
)
|
)
|
||||||
?.let { openInCustomTab(it) }
|
?.let { openInCustomTab(it) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class FtueAuthSignUpSignInSelectionFragment @Inject constructor() : AbstractSSOF
|
||||||
viewModel.getSsoUrl(
|
viewModel.getSsoUrl(
|
||||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||||
deviceId = state.deviceId,
|
deviceId = state.deviceId,
|
||||||
providerId = provider?.id
|
provider = provider
|
||||||
)
|
)
|
||||||
?.let { openInCustomTab(it) }
|
?.let { openInCustomTab(it) }
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ class FtueAuthSignUpSignInSelectionFragment @Inject constructor() : AbstractSSOF
|
||||||
viewModel.getSsoUrl(
|
viewModel.getSsoUrl(
|
||||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||||
deviceId = state.deviceId,
|
deviceId = state.deviceId,
|
||||||
providerId = null
|
provider = null
|
||||||
)
|
)
|
||||||
?.let { openInCustomTab(it) }
|
?.let { openInCustomTab(it) }
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue