mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Automatically sign out when toggling the SSS feature flag. (#3071)
This commit is contained in:
parent
9879552b46
commit
bf22250b45
@ -7501,7 +7501,7 @@
|
||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 1.0.27;
|
||||
version = 1.0.28;
|
||||
};
|
||||
};
|
||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||
|
@ -149,8 +149,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "3a1f56a8dc2b14c93e562ece82fbf780d2f79704",
|
||||
"version" : "1.0.27"
|
||||
"revision" : "1a1cbc9d9d43a188d9b07fe00a141d02f7c43c7c",
|
||||
"version" : "1.0.28"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -64,7 +64,6 @@ final class AppSettings {
|
||||
static func resetSessionSpecificSettings() {
|
||||
MXLog.warning("Resetting the user session specific AppSettings.")
|
||||
store.removeObject(forKey: UserDefaultsKeys.hasRunIdentityConfirmationOnboarding.rawValue)
|
||||
store.removeObject(forKey: UserDefaultsKeys.simplifiedSlidingSyncEnabled.rawValue)
|
||||
}
|
||||
|
||||
static func configureWithSuiteName(_ name: String) {
|
||||
|
@ -233,6 +233,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
switch action {
|
||||
case .clearCache:
|
||||
actionsSubject.send(.clearCache)
|
||||
case .forceLogout:
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
@ -21,15 +21,20 @@ extension ClientBuilder {
|
||||
/// A helper method that applies the common builder modifiers needed for the app.
|
||||
static func baseBuilder(setupEncryption: Bool = true,
|
||||
httpProxy: String? = nil,
|
||||
slidingSync: ClientBuilderSlidingSync,
|
||||
slidingSyncProxy: URL? = nil,
|
||||
sessionDelegate: ClientSessionDelegate,
|
||||
simplifiedSlidingSyncEnabled: Bool,
|
||||
appHooks: AppHooks) -> ClientBuilder {
|
||||
var builder = ClientBuilder()
|
||||
.slidingSyncProxy(slidingSyncProxy: slidingSyncProxy?.absoluteString)
|
||||
.enableCrossProcessRefreshLock(processId: InfoPlistReader.main.bundleIdentifier, sessionDelegate: sessionDelegate)
|
||||
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent())
|
||||
.simplifiedSlidingSync(enable: simplifiedSlidingSyncEnabled)
|
||||
|
||||
builder = switch slidingSync {
|
||||
case .restored: builder
|
||||
case .discovered: builder.requiresSlidingSync()
|
||||
case .simplified: builder.simplifiedSlidingSync(enable: true)
|
||||
}
|
||||
|
||||
if setupEncryption {
|
||||
builder = builder
|
||||
@ -45,3 +50,12 @@ extension ClientBuilder {
|
||||
return appHooks.clientBuilderHook.configure(builder)
|
||||
}
|
||||
}
|
||||
|
||||
enum ClientBuilderSlidingSync {
|
||||
/// The proxy will be supplied when restoring the Session.
|
||||
case restored
|
||||
/// A proxy must be discovered whilst building the session.
|
||||
case discovered
|
||||
/// Use Simplified Sliding Sync (discovery isn't a thing yet).
|
||||
case simplified
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import SwiftUI
|
||||
|
||||
enum DeveloperOptionsScreenCoordinatorAction {
|
||||
case clearCache
|
||||
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||
case forceLogout
|
||||
}
|
||||
|
||||
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
@ -42,6 +44,8 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
switch action {
|
||||
case .clearCache:
|
||||
actionsSubject.send(.clearCache)
|
||||
case .forceLogout:
|
||||
actionsSubject.send(.forceLogout)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
@ -18,6 +18,8 @@ import Foundation
|
||||
|
||||
enum DeveloperOptionsScreenViewModelAction {
|
||||
case clearCache
|
||||
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||
case forceLogout
|
||||
}
|
||||
|
||||
struct DeveloperOptionsScreenViewState: BindableState {
|
||||
|
@ -31,6 +31,16 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
|
||||
|
||||
super.init(initialViewState: state)
|
||||
|
||||
context.$viewState
|
||||
.map(\.bindings.simplifiedSlidingSyncEnabled)
|
||||
.removeDuplicates()
|
||||
.dropFirst() // Ignore the initial value received when opening the screen.
|
||||
.sink { [weak self] isEnabled in
|
||||
MXLog.error("Toggled simplifiedSlidingSyncEnabled: \(isEnabled). Signing out.")
|
||||
self?.actionsSubject.send(.forceLogout)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
override func process(viewAction: DeveloperOptionsScreenViewAction) {
|
||||
|
@ -30,7 +30,7 @@ struct DeveloperOptionsScreen: View {
|
||||
Section("Sliding Sync") {
|
||||
Toggle(isOn: $context.simplifiedSlidingSyncEnabled) {
|
||||
Text("Simplified Sliding Sync")
|
||||
Text("Requires app reboot")
|
||||
Text("When toggled you'll be logged out of the app and will need to log in again.")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,13 +141,12 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
||||
private func makeClientBuilder() -> ClientBuilder {
|
||||
ClientBuilder
|
||||
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
||||
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .discovered,
|
||||
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
||||
sessionDelegate: userSessionStore.clientSessionDelegate,
|
||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
||||
appHooks: appHooks)
|
||||
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
||||
.passphrase(passphrase: passphrase)
|
||||
.requiresSlidingSync()
|
||||
}
|
||||
|
||||
private func userSession(for client: Client) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
|
||||
|
@ -59,13 +59,12 @@ final class QRCodeLoginService: QRCodeLoginServiceProtocol {
|
||||
do {
|
||||
let client = try await ClientBuilder
|
||||
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
||||
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .discovered,
|
||||
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
||||
sessionDelegate: userSessionStore.clientSessionDelegate,
|
||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
||||
appHooks: appHooks)
|
||||
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
||||
.passphrase(passphrase: passphrase)
|
||||
.requiresSlidingSync()
|
||||
.buildWithQrCode(qrCodeData: qrData, oidcConfiguration: appSettings.oidcConfiguration.rustValue, progressListener: listener)
|
||||
return await login(client: client)
|
||||
} catch let error as HumanQrLoginError {
|
||||
|
@ -124,8 +124,8 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
|
||||
let builder = ClientBuilder
|
||||
.baseBuilder(httpProxy: URL(string: homeserverURL)?.globalProxy,
|
||||
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .restored,
|
||||
sessionDelegate: keychainController,
|
||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
||||
appHooks: appHooks)
|
||||
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
||||
.username(username: credentials.userID)
|
||||
|
@ -35,8 +35,8 @@ final class NSEUserSession {
|
||||
let clientBuilder = ClientBuilder
|
||||
.baseBuilder(setupEncryption: false,
|
||||
httpProxy: URL(string: homeserverURL)?.globalProxy,
|
||||
slidingSync: simplifiedSlidingSyncEnabled ? .simplified : .restored,
|
||||
sessionDelegate: clientSessionDelegate,
|
||||
simplifiedSlidingSyncEnabled: simplifiedSlidingSyncEnabled,
|
||||
appHooks: appHooks)
|
||||
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
||||
.username(username: credentials.userID)
|
||||
|
@ -60,7 +60,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||
exactVersion: 1.0.27
|
||||
exactVersion: 1.0.28
|
||||
# path: ../matrix-rust-sdk
|
||||
Compound:
|
||||
url: https://github.com/element-hq/compound-ios
|
||||
|
Loading…
x
Reference in New Issue
Block a user