From ec57ff1b030d690da47f7c0217ffcd701ac81bda Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Wed, 9 Mar 2022 11:07:39 +0100 Subject: [PATCH] Adds attempt at SSO session restore --- .../im/vector/app/features/login/LoginActivity.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index 499548ce78..f143929978 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -37,6 +37,7 @@ import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.extensions.exhaustive import im.vector.app.core.platform.VectorBaseActivity +import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.ActivityLoginBinding import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.HomeActivity @@ -252,7 +253,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA // It depends on the LoginMode when (state.loginMode) { LoginMode.Unknown, - is LoginMode.Sso, + is LoginMode.Sso -> launchSsoFlow() is LoginMode.SsoAndPassword, LoginMode.Password -> addFragmentToBackstack(views.loginFragmentContainer, LoginFragment::class.java, @@ -268,6 +269,16 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA }.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 */