2017-02-10 22:15:01 +08:00
|
|
|
//
|
|
|
|
|
// AddPasswordTableViewController.swift
|
|
|
|
|
// pass
|
|
|
|
|
//
|
|
|
|
|
// Created by Mingshen Sun on 10/2/2017.
|
|
|
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
2017-06-13 11:42:49 +08:00
|
|
|
import passKit
|
2020-06-28 21:25:40 +02:00
|
|
|
import UIKit
|
2017-02-10 22:15:01 +08:00
|
|
|
|
2017-03-09 03:19:36 +08:00
|
|
|
class AddPasswordTableViewController: PasswordEditorTableViewController {
|
2017-10-15 16:49:33 +08:00
|
|
|
var defaultDirPrefix = ""
|
2017-02-10 22:15:01 +08:00
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
2020-02-22 23:23:02 +08:00
|
|
|
tableData[0][0][PasswordEditorCellKey.content] = defaultDirPrefix
|
2017-02-11 20:45:56 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
override func shouldPerformSegue(withIdentifier identifier: String, sender _: Any?) -> Bool {
|
2017-03-09 02:39:13 +08:00
|
|
|
if identifier == "saveAddPasswordSegue" {
|
|
|
|
|
// check PGP key
|
2019-09-08 23:00:46 +02:00
|
|
|
guard PGPAgent.shared.isPrepared else {
|
2019-01-14 20:57:45 +01:00
|
|
|
let alertTitle = "CannotAddPassword".localize()
|
|
|
|
|
let alertMessage = "PgpKeyNotSet.".localize()
|
2017-03-09 02:39:13 +08:00
|
|
|
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)
|
|
|
|
|
return false
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-03-09 02:39:13 +08:00
|
|
|
// check name
|
2020-02-22 23:23:02 +08:00
|
|
|
guard checkName() else {
|
2017-03-09 02:39:13 +08:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2021-01-17 19:49:05 -08:00
|
|
|
@IBAction
|
2021-01-31 13:17:37 +01:00
|
|
|
private func cancel(_: Any) {
|
2021-01-17 19:49:05 -08:00
|
|
|
navigationController?.popViewController(animated: true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-10 22:15:01 +08:00
|
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
2017-04-08 03:08:12 +08:00
|
|
|
super.prepare(for: segue, sender: sender)
|
|
|
|
|
if segue.identifier == "saveAddPasswordSegue" {
|
2017-10-15 21:37:00 +08:00
|
|
|
let (name, url) = getNameURL()
|
2017-04-23 10:03:09 -07:00
|
|
|
password = Password(name: name, url: url, plainText: plainText)
|
2017-02-11 16:12:10 +08:00
|
|
|
}
|
2017-02-10 22:15:01 +08:00
|
|
|
}
|
|
|
|
|
}
|