mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +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.HomeServerHistoryService
|
||||
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.registration.FlowResult
|
||||
import org.matrix.android.sdk.api.auth.registration.RegistrationWizard
|
||||
|
@ -292,7 +293,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
is RegistrationResult.Complete -> onSessionCreated(
|
||||
it.session,
|
||||
authenticationDescription = AuthenticationDescription.AccountCreated(
|
||||
AuthenticationDescription.AuthenticationType.Password
|
||||
awaitState().selectedAuthenticationState.type ?: AuthenticationDescription.AuthenticationType.Other
|
||||
)
|
||||
)
|
||||
is RegistrationResult.NextStep -> onFlowResponse(it.flowResult, onNextRegistrationStepAction)
|
||||
|
@ -324,6 +325,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
private fun OnboardingViewState.hasSelectedMatrixOrg() = selectedHomeserver.userFacingUrl == matrixOrgUrl
|
||||
|
||||
private fun handleRegisterWith(action: AuthenticateAction.Register) {
|
||||
setState { copy(selectedAuthenticationState = SelectedAuthenticationState(AuthenticationDescription.AuthenticationType.Password)) }
|
||||
reAuthHelper.data = action.password
|
||||
handleRegisterAction(
|
||||
RegisterAction.CreateAccount(
|
||||
|
@ -750,8 +752,9 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
return loginConfig?.homeServerUrl
|
||||
}
|
||||
|
||||
fun getSsoUrl(redirectUrl: String, deviceId: String?, providerId: String?): String? {
|
||||
return authenticationService.getSsoUrl(redirectUrl, deviceId, providerId)
|
||||
fun getSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
|
||||
setState { copy(selectedAuthenticationState = SelectedAuthenticationState(provider.toAuthenticationType())) }
|
||||
return authenticationService.getSsoUrl(redirectUrl, deviceId, provider?.id)
|
||||
}
|
||||
|
||||
fun getFallbackUrl(forSignIn: Boolean, deviceId: String?): String? {
|
||||
|
|
|
@ -51,6 +51,9 @@ data class OnboardingViewState(
|
|||
@PersistState
|
||||
val selectedHomeserver: SelectedHomeserverState = SelectedHomeserverState(),
|
||||
|
||||
@PersistState
|
||||
val selectedAuthenticationState: SelectedAuthenticationState = SelectedAuthenticationState(),
|
||||
|
||||
@PersistState
|
||||
val personalizationState: PersonalizationState = PersonalizationState()
|
||||
) : MavericksState
|
||||
|
@ -80,3 +83,8 @@ data class PersonalizationState(
|
|||
|
||||
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(
|
||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||
deviceId = state.deviceId,
|
||||
providerId = null
|
||||
provider = null
|
||||
)
|
||||
?.let { prefetchUrl(it) }
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||
viewModel.getSsoUrl(
|
||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||
deviceId = deviceId,
|
||||
providerId = provider?.id
|
||||
provider = provider
|
||||
)?.let { openInCustomTab(it) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ class FtueAuthLoginFragment @Inject constructor() : AbstractSSOFtueAuthFragment<
|
|||
viewModel.getSsoUrl(
|
||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||
deviceId = state.deviceId,
|
||||
providerId = provider?.id
|
||||
provider = provider
|
||||
)
|
||||
?.let { openInCustomTab(it) }
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class FtueAuthSignUpSignInSelectionFragment @Inject constructor() : AbstractSSOF
|
|||
viewModel.getSsoUrl(
|
||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||
deviceId = state.deviceId,
|
||||
providerId = provider?.id
|
||||
provider = provider
|
||||
)
|
||||
?.let { openInCustomTab(it) }
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class FtueAuthSignUpSignInSelectionFragment @Inject constructor() : AbstractSSOF
|
|||
viewModel.getSsoUrl(
|
||||
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
|
||||
deviceId = state.deviceId,
|
||||
providerId = null
|
||||
provider = null
|
||||
)
|
||||
?.let { openInCustomTab(it) }
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue