From bebcaa012bfafb5ab1a8ee4db11feffd3843c52c Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 6 Feb 2019 03:23:51 +0100 Subject: PrivateDataConfirmation: prompt with touch/face/pin/password ID for viewing/exporting keys Signed-off-by: Jason A. Donenfeld --- .../SettingsTableViewController.swift | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift') diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift index 64cd0f7..3addea4 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift @@ -86,22 +86,25 @@ class SettingsTableViewController: UITableViewController { } func exportConfigurationsAsZipFile(sourceView: UIView) { - guard let tunnelsManager = tunnelsManager else { return } - guard let destinationDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } - - let destinationURL = destinationDir.appendingPathComponent("wireguard-export.zip") - _ = FileManager.deleteFile(at: destinationURL) + PrivateDataConfirmation.confirmAccess(to: tr("iosExportPrivateData")) { [weak self] in + guard let self = self else { return } + guard let tunnelsManager = self.tunnelsManager else { return } + guard let destinationDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } + + let destinationURL = destinationDir.appendingPathComponent("wireguard-export.zip") + _ = FileManager.deleteFile(at: destinationURL) + + let count = tunnelsManager.numberOfTunnels() + let tunnelConfigurations = (0 ..< count).compactMap { tunnelsManager.tunnel(at: $0).tunnelConfiguration } + ZipExporter.exportConfigFiles(tunnelConfigurations: tunnelConfigurations, to: destinationURL) { [weak self] error in + if let error = error { + ErrorPresenter.showErrorAlert(error: error, from: self) + return + } - let count = tunnelsManager.numberOfTunnels() - let tunnelConfigurations = (0 ..< count).compactMap { tunnelsManager.tunnel(at: $0).tunnelConfiguration } - ZipExporter.exportConfigFiles(tunnelConfigurations: tunnelConfigurations, to: destinationURL) { [weak self] error in - if let error = error { - ErrorPresenter.showErrorAlert(error: error, from: self) - return + let fileExportVC = UIDocumentPickerViewController(url: destinationURL, in: .exportToService) + self?.present(fileExportVC, animated: true, completion: nil) } - - let fileExportVC = UIDocumentPickerViewController(url: destinationURL, in: .exportToService) - self?.present(fileExportVC, animated: true, completion: nil) } } -- cgit v1.2.3-59-g8ed1b