Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {

// MARK: - Private methods

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

crossSigning.setup(withAuthParams: authenticationParameters) { [weak self] in
Expand All @@ -64,7 +64,8 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
guard let self else { return }

if let responseData = (error as NSError).userInfo[MXHTTPClientErrorResponseDataKey] as? [AnyHashable: Any],
let authenticationSession = MXAuthenticationSession(fromJSON: responseData) {
let authenticationSession = MXAuthenticationSession(fromJSON: responseData),
!hasAuthenticated { // Don't re-presenting authentication if the user closes the web view without finishing.
showReauthentication(authenticationSession: authenticationSession)
} else {
delegate?.crossSigningSetupCoordinator(self, didFailWithError: error)
Expand Down Expand Up @@ -93,7 +94,7 @@ final class CrossSigningSetupCoordinator: CrossSigningSetupCoordinatorType {
extension CrossSigningSetupCoordinator: ReauthenticationCoordinatorDelegate {

func reauthenticationCoordinatorDidComplete(_ coordinator: ReauthenticationCoordinatorType, withAuthenticationParameters authenticationParameters: [String: Any]?) {
self.setupCrossSigning(with: authenticationParameters ?? [:])
self.setupCrossSigning(with: authenticationParameters ?? [:], hasAuthenticated: true)
}

func reauthenticationCoordinatorDidCancel(_ coordinator: ReauthenticationCoordinatorType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ final class KeyVerificationCoordinator: KeyVerificationCoordinatorType {
return coordinator
}

private func showSecretsReset() {
let coordinator = SecretsResetCoordinator(session: self.session, isCancellable: false)
coordinator.delegate = self
coordinator.start()

self.add(childCoordinator: coordinator)
self.navigationRouter.push(coordinator.toPresentable(), animated: true, popCompletion: { [weak self] in
self?.remove(childCoordinator: coordinator)
})
}

private func showSecretsRecovery(with recoveryMode: SecretsRecoveryMode) {
let coordinator = SecretsRecoveryCoordinator(session: self.session, recoveryMode: recoveryMode, recoveryGoal: .verifyDevice, navigationRouter: self.navigationRouter, cancellable: self.cancellable)
coordinator.delegate = self
Expand Down Expand Up @@ -436,9 +447,13 @@ extension KeyVerificationCoordinator: KeyVerificationSelfVerifyWaitCoordinatorDe
self.didCancel()
}

func keyVerificationSelfVerifyWaitCoordinator(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType, wantsToRecoverSecretsWith secretsRecoveryMode: SecretsRecoveryMode) {
func keyVerificationSelfVerifyWaitCoordinator(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType, wantsToRecoverSecretsWith secretsRecoveryMode: SecretsRecoveryMode) {
self.showSecretsRecovery(with: secretsRecoveryMode)
}

func keyVerificationSelfVerifyWaitCoordinatorWantsToResetSecrets(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType) {
self.showSecretsReset()
}
}

// MARK: - KeyVerificationScanConfirmationCoordinatorDelegate
Expand Down Expand Up @@ -466,3 +481,15 @@ extension KeyVerificationCoordinator: SecretsRecoveryCoordinatorDelegate {
self.didCancel()
}
}

// MARK: - SecretsResetCoordinatorDelegate
extension KeyVerificationCoordinator: SecretsResetCoordinatorDelegate {

func secretsResetCoordinatorDidResetSecrets(_ coordinator: SecretsResetCoordinatorType) {
self.showVerified(animated: true)
}

func secretsResetCoordinatorDidCancel(_ coordinator: SecretsResetCoordinatorType) {
// Not used, the cancel button is hidden.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ extension KeyVerificationSelfVerifyWaitCoordinator: KeyVerificationSelfVerifyWai
func keyVerificationSelfVerifyWaitViewModel(_ coordinator: KeyVerificationSelfVerifyWaitViewModelType, wantsToRecoverSecretsWith secretsRecoveryMode: SecretsRecoveryMode) {
self.delegate?.keyVerificationSelfVerifyWaitCoordinator(self, wantsToRecoverSecretsWith: secretsRecoveryMode)
}

func keyVerificationSelfVerifyWaitViewModelWantsToResetSecrets(_ viewModel: KeyVerificationSelfVerifyWaitViewModelType) {
self.delegate?.keyVerificationSelfVerifyWaitCoordinatorWantsToResetSecrets(self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protocol KeyVerificationSelfVerifyWaitCoordinatorDelegate: AnyObject {
func keyVerificationSelfVerifyWaitCoordinator(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType, didAcceptIncomingSASTransaction incomingSASTransaction: MXSASTransaction)
func keyVerificationSelfVerifyWaitCoordinatorDidCancel(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType)
func keyVerificationSelfVerifyWaitCoordinator(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType, wantsToRecoverSecretsWith secretsRecoveryMode: SecretsRecoveryMode)
func keyVerificationSelfVerifyWaitCoordinatorWantsToResetSecrets(_ coordinator: KeyVerificationSelfVerifyWaitCoordinatorType)
}

/// `KeyVerificationSelfVerifyWaitCoordinatorType` is a protocol describing a Coordinator that handle key backup setup passphrase navigation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ enum KeyVerificationSelfVerifyWaitViewAction {
case loadData
case cancel
case recoverSecrets
case resetSecrets
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="79A-qb-tmk">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="79A-qb-tmk">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -17,13 +17,13 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="asO-rj-82y">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tIM-sl-gwE">
<rect key="frame" x="0.0" y="0.0" width="375" height="562"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="652"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IlB-Ch-LEo">
<rect key="frame" x="0.0" y="0.0" width="375" height="562"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="652"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Open Element on your other device" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="aOD-RJ-1qU">
<rect key="frame" x="20" y="20" width="335" height="67"/>
Expand Down Expand Up @@ -73,7 +73,7 @@ Open Element on one of your other devices and follow the instructions.</string>
</constraints>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="8oJ-o6-DLK">
<rect key="frame" x="20" y="329" width="335" height="233"/>
<rect key="frame" x="20" y="329" width="335" height="323"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dXT-cL-ukJ">
<rect key="frame" x="0.0" y="0.0" width="335" height="114.5"/>
Expand Down Expand Up @@ -133,6 +133,35 @@ Open Element on one of your other devices and follow the instructions.</string>
<constraint firstAttribute="trailing" secondItem="OEt-k0-vgM" secondAttribute="trailing" id="yQK-YS-7Yr"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MZS-LD-c5M">
<rect key="frame" x="0.0" y="233" width="335" height="90"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dgm-0y-4Zm">
<rect key="frame" x="20" y="20" width="295" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="gMu-pN-Qn2"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<inset key="contentEdgeInsets" minX="20" minY="0.0" maxX="20" maxY="0.0"/>
<state key="normal" title="Forgot or lost all recovery options? Reset everything">
<color key="titleColor" systemColor="darkTextColor"/>
</state>
<state key="disabled">
<color key="titleColor" red="0.47843137250000001" green="0.78823529410000004" blue="0.63137254899999995" alpha="0.5" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="resetSecretsButtonAction:" destination="79A-qb-tmk" eventType="touchUpInside" id="z9Y-Vc-Qv6"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="dgm-0y-4Zm" secondAttribute="bottom" constant="20" symbolic="YES" id="0RW-EA-zD8"/>
<constraint firstItem="dgm-0y-4Zm" firstAttribute="leading" secondItem="MZS-LD-c5M" secondAttribute="leading" constant="20" symbolic="YES" id="IlA-bw-Ge3"/>
<constraint firstAttribute="trailing" secondItem="dgm-0y-4Zm" secondAttribute="trailing" constant="20" symbolic="YES" id="bXE-8Z-xlt"/>
<constraint firstItem="dgm-0y-4Zm" firstAttribute="top" secondItem="MZS-LD-c5M" secondAttribute="top" constant="20" symbolic="YES" id="n0t-Px-2Gw"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="nf8-Ye-b9r" firstAttribute="width" secondItem="8oJ-o6-DLK" secondAttribute="width" id="ZNi-0G-uDR"/>
Expand Down Expand Up @@ -197,6 +226,8 @@ Open Element on one of your other devices and follow the instructions.</string>
<outlet property="recoverSecretsAvailabilityLoadingLabel" destination="A4x-sK-d5C" id="n5k-IO-RkV"/>
<outlet property="recoverSecretsButton" destination="OEt-k0-vgM" id="RHU-ps-4m7"/>
<outlet property="recoverSecretsContainerView" destination="nf8-Ye-b9r" id="4az-pe-0Uc"/>
<outlet property="resetSecretsButton" destination="dgm-0y-4Zm" id="5di-fv-zHX"/>
<outlet property="resetSecretsContainerView" destination="MZS-LD-c5M" id="V59-pG-iMb"/>
<outlet property="titleLabel" destination="aOD-RJ-1qU" id="qvC-fk-TiU"/>
</connections>
</viewController>
Expand All @@ -208,5 +239,8 @@ Open Element on one of your other devices and follow the instructions.</string>
<resources>
<image name="monitor" width="48" height="48"/>
<image name="smartphone" width="48" height="48"/>
<systemColor name="darkTextColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
@IBOutlet private weak var recoverSecretsButton: RoundedButton!
@IBOutlet private weak var recoverSecretsAdditionalInformationLabel: UILabel!

@IBOutlet private weak var resetSecretsContainerView: UIView!
@IBOutlet private weak var resetSecretsButton: UIButton!

// MARK: Private

private var viewModel: KeyVerificationSelfVerifyWaitViewModelType!
Expand Down Expand Up @@ -101,6 +104,13 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
self.mobileClientImageView.tintColor = theme.tintColor
self.recoverSecretsAvailabilityLoadingLabel.textColor = theme.textSecondaryColor
self.recoverSecretsAvailabilityActivityIndicatorView.color = theme.tintColor

// Reset secrets button
let resetSecretsAttributedString = NSMutableAttributedString(string: VectorL10n.secretsRecoveryResetActionPart1,
attributes: [.foregroundColor: self.theme.textPrimaryColor])
resetSecretsAttributedString.append(NSAttributedString(string: VectorL10n.secretsRecoveryResetActionPart2,
attributes: [.foregroundColor: self.theme.warningColor]))
self.resetSecretsButton.setAttributedTitle(resetSecretsAttributedString, for: .normal)
}

private func registerThemeServiceDidChangeThemeNotification() {
Expand All @@ -121,6 +131,9 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {

self.navigationItem.rightBarButtonItem = cancelBarButtonItem
self.cancelBarButtonItem = cancelBarButtonItem

self.resetSecretsButton.vc_enableMultiLinesTitle()
self.resetSecretsButton.isHidden = !RiotSettings.shared.secretsRecoveryAllowReset
}

self.titleLabel.text = VectorL10n.deviceVerificationSelfVerifyOpenOnOtherDeviceTitle(AppInfo.current.displayName)
Expand Down Expand Up @@ -158,22 +171,26 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
self.recoverSecretsAvailabilityActivityIndicatorView.startAnimating()
self.recoverSecretsAvailabilityLoadingContainerView.isHidden = false
self.recoverSecretsContainerView.isHidden = true
self.resetSecretsContainerView.isHidden = true
}

private func renderLoaded(viewData: KeyVerificationSelfVerifyWaitViewData) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)

self.cancelBarButtonItem?.title = viewData.isNewSignIn ? VectorL10n.skip : VectorL10n.cancel

let hideRecoverSecrets: Bool
let hideResetSecrets: Bool
let recoverSecretsButtonTitle: String?

switch viewData.secretsRecoveryAvailability {
case .notAvailable:
hideRecoverSecrets = true
hideResetSecrets = false
recoverSecretsButtonTitle = nil
case .available(let secretsRecoveryMode):
hideRecoverSecrets = false
hideResetSecrets = true

switch secretsRecoveryMode {
case .passphraseOrKey:
Expand All @@ -187,6 +204,8 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
self.recoverSecretsAvailabilityActivityIndicatorView.stopAnimating()
self.recoverSecretsContainerView.isHidden = hideRecoverSecrets
self.recoverSecretsButton.setTitle(recoverSecretsButtonTitle, for: .normal)

self.resetSecretsContainerView.isHidden = hideResetSecrets
}

private func renderCancelled(reason: MXTransactionCancelCode) {
Expand Down Expand Up @@ -223,6 +242,10 @@ final class KeyVerificationSelfVerifyWaitViewController: UIViewController {
@IBAction private func recoverSecretsButtonAction(_ sender: Any) {
self.viewModel.process(viewAction: .recoverSecrets)
}

@IBAction private func resetSecretsButtonAction(_ sender: Any) {
self.viewModel.process(viewAction: .resetSecrets)
}
}


Expand Down
Loading
Loading