Skip to content

Commit 880ed69

Browse files
committed
OIDC redirect to the web page to delete a session (new session manager) #8616
1 parent 8941e63 commit 880ed69

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import im.vector.app.core.platform.VectorMenuProvider
3939
import im.vector.app.core.resources.ColorProvider
4040
import im.vector.app.core.resources.DrawableProvider
4141
import im.vector.app.core.resources.StringProvider
42+
import im.vector.app.core.utils.openUrlInChromeCustomTab
4243
import im.vector.app.databinding.FragmentSessionOverviewBinding
4344
import im.vector.app.features.auth.ReAuthActivity
4445
import im.vector.app.features.crypto.recover.SetupMode
@@ -135,10 +136,19 @@ class SessionOverviewFragment :
135136
activity?.let { SignOutUiWorker(it).perform() }
136137
}
137138

138-
private fun confirmSignoutOtherSession() {
139-
activity?.let {
140-
buildConfirmSignoutDialogUseCase.execute(it, this::signoutSession)
141-
.show()
139+
private fun confirmSignoutOtherSession() = withState(viewModel) { state ->
140+
if (state.externalAccountManagementUrl != null) {
141+
// Manage in external account manager
142+
openUrlInChromeCustomTab(
143+
requireContext(),
144+
null,
145+
state.externalAccountManagementUrl.removeSuffix("/") + "?action=session_end&device_id=${state.deviceId}"
146+
)
147+
} else {
148+
activity?.let {
149+
buildConfirmSignoutDialogUseCase.execute(it, this::signoutSession)
150+
.show()
151+
}
142152
}
143153
}
144154

vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ class SessionOverviewViewModel @AssistedInject constructor(
7575
observeNotificationsStatus(initialState.deviceId)
7676
refreshIpAddressVisibility()
7777
observePreferences()
78+
initExternalAccountManagementUrl()
79+
}
80+
81+
private fun initExternalAccountManagementUrl() {
82+
setState {
83+
copy(
84+
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession()
85+
?.homeServerCapabilitiesService()
86+
?.getHomeServerCapabilities()
87+
?.externalAccountManagementUrl
88+
)
89+
}
7890
}
7991

8092
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {

vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data class SessionOverviewViewState(
2929
val isLoading: Boolean = false,
3030
val notificationsStatus: NotificationsStatus = NotificationsStatus.NOT_SUPPORTED,
3131
val isShowingIpAddress: Boolean = false,
32+
val externalAccountManagementUrl: String? = null,
3233
) : MavericksState {
3334
constructor(args: SessionOverviewArgs) : this(
3435
deviceId = args.deviceId

0 commit comments

Comments
 (0)