Rewrite PasswordViewController
This commit is contained in:
parent
372e897350
commit
68077bf04c
10 changed files with 676 additions and 729 deletions
28
pass/Services/PasswordEncryptor.swift
Normal file
28
pass/Services/PasswordEncryptor.swift
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import passKit
|
||||
|
||||
func encryptPassword(in controller: UIViewController, with password: Password, keyID: String? = nil, completion: @escaping (() -> Void)) {
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
do {
|
||||
_ = try PasswordStore.shared.add(password: password, keyID: keyID)
|
||||
DispatchQueue.main.async {
|
||||
completion()
|
||||
}
|
||||
} catch let AppError.pgpPublicKeyNotFound(keyID: key) {
|
||||
DispatchQueue.main.async {
|
||||
let alert = UIAlertController(title: "Cannot Encrypt Password", message: AppError.pgpPublicKeyNotFound(keyID: key).localizedDescription, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction.cancelAndPopView(controller: controller))
|
||||
let selectKey = UIAlertAction.selectKey(controller: controller) { action in
|
||||
encryptPassword(in: controller, with: password, keyID: action.title, completion: completion)
|
||||
}
|
||||
alert.addAction(selectKey)
|
||||
|
||||
controller.present(alert, animated: true)
|
||||
}
|
||||
return
|
||||
} catch {
|
||||
DispatchQueue.main.async {
|
||||
Utils.alert(title: "Error".localize(), message: error.localizedDescription, controller: controller, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue