Adds attempt at SSO session restore

This commit is contained in:
ericdecanini 2022-03-09 11:07:39 +01:00
parent 6836a12557
commit ec57ff1b03

View file

@ -37,6 +37,7 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.extensions.addFragmentToBackstack
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.utils.openUrlInChromeCustomTab
import im.vector.app.databinding.ActivityLoginBinding import im.vector.app.databinding.ActivityLoginBinding
import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.plan.MobileScreen
import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.HomeActivity
@ -252,7 +253,7 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), UnlockedA
// It depends on the LoginMode // It depends on the LoginMode
when (state.loginMode) { when (state.loginMode) {
LoginMode.Unknown, LoginMode.Unknown,
is LoginMode.Sso, is LoginMode.Sso -> launchSsoFlow()
is LoginMode.SsoAndPassword, is LoginMode.SsoAndPassword,
LoginMode.Password -> addFragmentToBackstack(views.loginFragmentContainer, LoginMode.Password -> addFragmentToBackstack(views.loginFragmentContainer,
LoginFragment::class.java, LoginFragment::class.java,
@ -268,6 +269,16 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), UnlockedA
}.exhaustive }.exhaustive
} }
private fun launchSsoFlow() = withState(loginViewModel) { state ->
loginViewModel.getSsoUrl(
redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL,
deviceId = state.deviceId,
providerId = null,
)?.let { ssoUrl ->
openUrlInChromeCustomTab(this, null, ssoUrl)
}
}
/** /**
* Handle the SSO redirection here * Handle the SSO redirection here
*/ */