fix: Fix Passphrase reset for new synapse behaviour (MESSENGER-7295)

This commit is contained in:
Frank Rotermund
2025-05-28 07:14:15 +02:00
parent a512c53fd2
commit 0ed9434f60
4 changed files with 38 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ final class CrossSigningService: NSObject {
}
func setupCrossSigningRequest() -> AuthenticatedEndpointRequest {
// bwi 7295 could be fixed here to by adding a fake master key to the request
let path = "\(kMXAPIPrefixPathUnstable)/keys/device_signing/upload"
return AuthenticatedEndpointRequest(path: path, httpMethod: "POST", params: [:])
}

View File

@@ -72,6 +72,23 @@ final class SecretsResetCoordinator: SecretsResetCoordinatorType {
coordinator.start()
self.add(childCoordinator: coordinator)
}
// bwi 7295 need to do authentication with session on an 401 error
private func showAuthentication(with session: MXAuthenticationSession) {
let reauthenticationCoordinatorParameters = ReauthenticationCoordinatorParameters(session: self.session,
presenter: self.toPresentable(),
title: nil,
message: BWIL10n.secretsResetAuthenticationMessage,
authenticationSession: session)
let coordinator = ReauthenticationCoordinator(parameters: reauthenticationCoordinatorParameters)
coordinator.delegate = self
coordinator.start()
self.add(childCoordinator: coordinator)
}
// bwi 7295 end
}
// MARK: - SecretsResetViewModelCoordinatorDelegate
@@ -81,6 +98,12 @@ extension SecretsResetCoordinator: SecretsResetViewModelCoordinatorDelegate {
self.showAuthentication(with: request)
}
// bwi 7295 need to do authentication with session on an 401 error
func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith session: MXAuthenticationSession) {
self.showAuthentication(with: session)
}
// bwi 7295 end
func secretsResetViewModelDidResetSecrets(_ viewModel: SecretsResetViewModelType) {
self.delegate?.secretsResetCoordinatorDidResetSecrets(self)
}

View File

@@ -92,7 +92,18 @@ final class SecretsResetViewModel: SecretsResetViewModelType {
guard let self = self else {
return
}
self.update(viewState: .error(error))
// bwi 7295 need to do authentication with session on an 401 error
let nsError = error as NSError
if let matrixData = nsError.userInfo["com.matrixsdk.httpclient.error.response.data"] as? [String: Any],
let session = MXAuthenticationSession(fromJSON: matrixData) {
self.coordinatorDelegate?.secretsResetViewModel(self, needsToAuthenticateWith: session)
} else {
self.update(viewState: .error(error))
}
// bwi 7295 end
})
}

View File

@@ -24,6 +24,8 @@ protocol SecretsResetViewModelViewDelegate: AnyObject {
protocol SecretsResetViewModelCoordinatorDelegate: AnyObject {
func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith request: AuthenticatedEndpointRequest)
// bwi 7295 need to do authentication with session
func secretsResetViewModel(_ viewModel: SecretsResetViewModelType, needsToAuthenticateWith session: MXAuthenticationSession)
func secretsResetViewModelDidResetSecrets(_ viewModel: SecretsResetViewModelType)
func secretsResetViewModelDidCancel(_ viewModel: SecretsResetViewModelType)
}