Skip to content

Commit

Permalink
Fix a bug where UIA for cross signing wasn't needed until after check…
Browse files Browse the repository at this point in the history
…ing for it.

This was due to the parameters not being present in the check, so we no longer check and instead do UIA on failure.
  • Loading branch information
pixlwave committed Nov 26, 2024
1 parent 0e6ad70 commit 514b8f6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Riot/Modules/CrossSigning/Setup/CrossSigningSetupCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
// MARK: - Public methods

func start() {
self.showReauthentication()
setupCrossSigning()
}

func toPresentable() -> UIViewController {
Expand All @@ -54,15 +54,14 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {

// MARK: - Private methods

private func showReauthentication() {

private func showReauthentication(authenticationSession: MXAuthenticationSession) {
let setupCrossSigningRequest = self.crossSigningService.setupCrossSigningRequest()

let reauthenticationParameters = ReauthenticationCoordinatorParameters(session: parameters.session,
presenter: parameters.presenter,
title: parameters.title,
message: parameters.message,
authenticatedEndpointRequest: setupCrossSigningRequest)
authenticationSession: authenticationSession)

let coordinator = ReauthenticationCoordinator(parameters: reauthenticationParameters)
coordinator.delegate = self
Expand All @@ -71,21 +70,21 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
coordinator.start()
}

private func setupCrossSigning(with authenticationParameters: [String: Any]) {
guard let crossSigning = self.parameters.session.crypto?.crossSigning else {
return
}
private func setupCrossSigning(with authenticationParameters: [String: Any] = [:]) {
guard let crossSigning = parameters.session.crypto?.crossSigning else { return }

crossSigning.setup(withAuthParams: authenticationParameters) { [weak self] in
guard let self = self else {
return
}
self.delegate?.crossSigningSetupCoordinatorDidComplete(self)
guard let self else { return }
delegate?.crossSigningSetupCoordinatorDidComplete(self)
} failure: { [weak self] error in
guard let self = self else {
return
guard let self else { return }

if let responseData = (error as NSError).userInfo[MXHTTPClientErrorResponseDataKey] as? [AnyHashable: Any],
let authenticationSession = MXAuthenticationSession(fromJSON: responseData) {
showReauthentication(authenticationSession: authenticationSession)
} else {
delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
}
self.delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
}
}
}
Expand Down

0 comments on commit 514b8f6

Please sign in to comment.