Add confirmation prompt for removing keys (fix #491)
This commit is contained in:
parent
7320319031
commit
ff6a1edf62
7 changed files with 42 additions and 9 deletions
|
|
@ -126,6 +126,7 @@
|
|||
9A5D06F525A56F0E00FA59D4 /* PasswordTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */; };
|
||||
9A5D070225A5769A00FA59D4 /* PasswordTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */; };
|
||||
9A652414244BB33300DA0A41 /* UIAlertActionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */; };
|
||||
9A74D2E0277D2F8C00F7BC44 /* UIAlertControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */; };
|
||||
9A78A7CC277BECE80093222D /* SVProgressHUD.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30F6C1B327664C7200BE5AB2 /* SVProgressHUD.xcframework */; };
|
||||
9A78A7CD277BECE80093222D /* SVProgressHUD.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 30F6C1B327664C7200BE5AB2 /* SVProgressHUD.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
9A8F9EBD259EA4C50027CE15 /* PasswordsTableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EBC259EA4C50027CE15 /* PasswordsTableDataSource.swift */; };
|
||||
|
|
@ -411,6 +412,7 @@
|
|||
9A5865EF25AA944B006719C2 /* SearchPassword.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SearchPassword.storyboard; sourceTree = "<group>"; };
|
||||
9A58665025AADB76006719C2 /* CredentialProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialProvider.swift; sourceTree = "<group>"; };
|
||||
9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertActionExtension.swift; sourceTree = "<group>"; };
|
||||
9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertControllerExtension.swift; sourceTree = "<group>"; };
|
||||
9A8F9EBC259EA4C50027CE15 /* PasswordsTableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordsTableDataSource.swift; sourceTree = "<group>"; };
|
||||
9A8F9ECB259ECB410027CE15 /* PasswordSelectionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordSelectionDelegate.swift; sourceTree = "<group>"; };
|
||||
9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordTableViewCell.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -654,6 +656,7 @@
|
|||
30697C3521F63C990064FCAC /* UIViewControllerExtension.swift */,
|
||||
30697C3821F63C990064FCAC /* UIViewExtension.swift */,
|
||||
9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */,
|
||||
9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1516,6 +1519,7 @@
|
|||
30697C2A21F63C5A0064FCAC /* NotificationNames.swift in Sources */,
|
||||
30CCA91623258C380048CA51 /* PGPInterface.swift in Sources */,
|
||||
30DAFD4A240985A7002456E7 /* Array+Slices.swift in Sources */,
|
||||
9A74D2E0277D2F8C00F7BC44 /* UIAlertControllerExtension.swift in Sources */,
|
||||
30697C4721F63CAB0064FCAC /* PasscodeLock.swift in Sources */,
|
||||
A2699ACD2402631400F36323 /* PasswordTableEntry.swift in Sources */,
|
||||
30697C3421F63C8B0064FCAC /* PasscodeLockViewController.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -314,10 +314,13 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
|
|||
if Defaults.gitSSHKeySource != nil {
|
||||
optionMenu.addAction(
|
||||
UIAlertAction(title: "RemoveSShKeys".localize(), style: .destructive) { _ in
|
||||
self.passwordStore.removeGitSSHKeys()
|
||||
Defaults.gitSSHKeySource = nil
|
||||
self.sshLabel?.isEnabled = false
|
||||
self.gitAuthenticationMethod = .password
|
||||
let alert = UIAlertController.removeConfirmationAlert(title: "RemoveSShKeys".localize(), message: "") { _ in
|
||||
self.passwordStore.removeGitSSHKeys()
|
||||
Defaults.gitSSHKeySource = nil
|
||||
self.sshLabel?.isEnabled = false
|
||||
self.gitAuthenticationMethod = .password
|
||||
}
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,11 +184,14 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
if Defaults.pgpKeySource != nil {
|
||||
optionMenu.addAction(
|
||||
UIAlertAction(title: "RemovePgpKeys".localize(), style: .destructive) { _ in
|
||||
self.keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey())
|
||||
self.keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey())
|
||||
PGPAgent.shared.uninitKeys()
|
||||
self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize()
|
||||
Defaults.pgpKeySource = nil
|
||||
let alert = UIAlertController.removeConfirmationAlert(title: "RemovePgpKeys".localize(), message: "") { _ in
|
||||
self.keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey())
|
||||
self.keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey())
|
||||
PGPAgent.shared.uninitKeys()
|
||||
self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize()
|
||||
Defaults.pgpKeySource = nil
|
||||
}
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@
|
|||
"On" = "An";
|
||||
"Off" = "Aus";
|
||||
"Save" = "Speichern";
|
||||
"Remove" = "Löschen";
|
||||
|
||||
// Lock screen
|
||||
"EnterPasscode" = "Passcode für Pass eingeben";
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@
|
|||
"On" = "On";
|
||||
"Off" = "Off";
|
||||
"Save" = "Save";
|
||||
"Remove" = "Remove";
|
||||
|
||||
// Lock screen
|
||||
"EnterPasscode" = "Enter passcode for Pass";
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ public extension UIAlertAction {
|
|||
UIAlertAction(title: "Ok".localize(), style: .default, handler: handler)
|
||||
}
|
||||
|
||||
static func remove(handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction {
|
||||
UIAlertAction(title: "Remove".localize(), style: .destructive, handler: handler)
|
||||
}
|
||||
|
||||
static func okAndPopView(controller: UIViewController) -> UIAlertAction {
|
||||
ok { _ in
|
||||
controller.navigationController?.popViewController(animated: true)
|
||||
|
|
|
|||
17
passKit/Extensions/UIAlertControllerExtension.swift
Normal file
17
passKit/Extensions/UIAlertControllerExtension.swift
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// UIAlertControllerExtension.swift
|
||||
// passKit
|
||||
//
|
||||
// Copyright © 2021 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension UIAlertController {
|
||||
class func removeConfirmationAlert(title: String, message: String, handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertController {
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction.remove(handler: handler))
|
||||
alert.addAction(UIAlertAction.cancel())
|
||||
return alert
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue