OIDC redirect to the web page to delete a session (new session manager) #8616

This commit is contained in:
Benoit Marty 2023-08-22 12:17:23 +02:00
parent 8941e6396c
commit 880ed69f97
3 changed files with 27 additions and 4 deletions

View File

@ -39,6 +39,7 @@ import im.vector.app.core.platform.VectorMenuProvider
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.DrawableProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.openUrlInChromeCustomTab
import im.vector.app.databinding.FragmentSessionOverviewBinding
import im.vector.app.features.auth.ReAuthActivity
import im.vector.app.features.crypto.recover.SetupMode
@ -135,12 +136,21 @@ class SessionOverviewFragment :
activity?.let { SignOutUiWorker(it).perform() }
}
private fun confirmSignoutOtherSession() {
private fun confirmSignoutOtherSession() = withState(viewModel) { state ->
if (state.externalAccountManagementUrl != null) {
// Manage in external account manager
openUrlInChromeCustomTab(
requireContext(),
null,
state.externalAccountManagementUrl.removeSuffix("/") + "?action=session_end&device_id=${state.deviceId}"
)
} else {
activity?.let {
buildConfirmSignoutDialogUseCase.execute(it, this::signoutSession)
.show()
}
}
}
private fun signoutSession() {
viewModel.handle(SessionOverviewAction.SignoutOtherSession)

View File

@ -75,6 +75,18 @@ class SessionOverviewViewModel @AssistedInject constructor(
observeNotificationsStatus(initialState.deviceId)
refreshIpAddressVisibility()
observePreferences()
initExternalAccountManagementUrl()
}
private fun initExternalAccountManagementUrl() {
setState {
copy(
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
?.homeServerCapabilitiesService()
?.getHomeServerCapabilities()
?.externalAccountManagementUrl
)
}
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {

View File

@ -29,6 +29,7 @@ data class SessionOverviewViewState(
val isLoading: Boolean = false,
val notificationsStatus: NotificationsStatus = NotificationsStatus.NOT_SUPPORTED,
val isShowingIpAddress: Boolean = false,
val externalAccountManagementUrl: String? = null,
) : MavericksState {
constructor(args: SessionOverviewArgs) : this(
deviceId = args.deviceId