diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard
index b48928e..84b3c31 100644
--- a/pass/Base.lproj/Main.storyboard
+++ b/pass/Base.lproj/Main.storyboard
@@ -482,7 +482,7 @@
-
+
diff --git a/pass/Controllers/GitServerSettingTableViewController.swift b/pass/Controllers/GitServerSettingTableViewController.swift
index 00eb3a9..4e680b9 100644
--- a/pass/Controllers/GitServerSettingTableViewController.swift
+++ b/pass/Controllers/GitServerSettingTableViewController.swift
@@ -107,11 +107,12 @@ class GitServerSettingTableViewController: UITableViewController {
tableView.deselectRow(at: indexPath, animated: true)
}
- @IBAction func save(_ sender: Any) {
+ private func doClone() {
if authenticationMethod == "Password" {
let alert = UIAlertController(title: "Password", message: "Please fill in the password of your Git account.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in
self.password = alert.textFields!.first!.text
+ self.passwordStore.gitPassword = self.password
if self.shouldPerformSegue(withIdentifier: "saveGitServerSettingSegue", sender: self) {
self.performSegue(withIdentifier: "saveGitServerSettingSegue", sender: self)
}
@@ -128,6 +129,19 @@ class GitServerSettingTableViewController: UITableViewController {
}
}
+ @IBAction func save(_ sender: Any) {
+ if passwordStore.repositoryExisted() {
+ let alert = UIAlertController(title: "Erase Current Password Store Data?", message: "A cloned password store exists. This operation will erase all local data. Data on your remote server will not be affected.", preferredStyle: UIAlertControllerStyle.alert)
+ alert.addAction(UIAlertAction(title: "Erase", style: UIAlertActionStyle.destructive, handler: { _ in
+ self.doClone()
+ }))
+ alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
+ self.present(alert, animated: true, completion: nil)
+ } else {
+ doClone()
+ }
+ }
+
private func gitSSHKeyExists() -> Bool {
return FileManager.default.fileExists(atPath: Globals.gitSSHPublicKeyPath) &&
FileManager.default.fileExists(atPath: Globals.gitSSHPrivateKeyPath)
diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift
index 5ffb1e1..a05ce5a 100644
--- a/pass/Controllers/SettingsTableViewController.swift
+++ b/pass/Controllers/SettingsTableViewController.swift
@@ -101,61 +101,53 @@ class SettingsTableViewController: UITableViewController {
let password = controller.password
let auth = controller.authenticationMethod
- if Defaults[.gitURL] == nil ||
- Defaults[.gitURL]!.absoluteString != gitRepostiroyURL ||
- auth != Defaults[.gitAuthenticationMethod] ||
- username != Defaults[.gitUsername] ||
- password != self.passwordStore.gitPassword ||
- self.passwordStore.repositoryExisted() == false {
-
- SVProgressHUD.setDefaultMaskType(.black)
- SVProgressHUD.setDefaultStyle(.light)
- SVProgressHUD.show(withStatus: "Prepare Repository")
- var gitCredential: GitCredential
- if auth == "Password" {
- gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password!, requestGitPassword: requestGitPassword))
- } else {
- gitCredential = GitCredential(
- credential: GitCredential.Credential.ssh(
- userName: username,
- password: Utils.getPasswordFromKeychain(name: "gitSSHPrivateKeyPassphrase") ?? "",
- publicKeyFile: Globals.gitSSHPublicKeyURL,
- privateKeyFile: Globals.gitSSHPrivateKeyURL,
- requestSSHKeyPassword: self.requestGitPassword
- )
+ SVProgressHUD.setDefaultMaskType(.black)
+ SVProgressHUD.setDefaultStyle(.light)
+ SVProgressHUD.show(withStatus: "Prepare Repository")
+ var gitCredential: GitCredential
+ if auth == "Password" {
+ gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password!, requestGitPassword: requestGitPassword))
+ } else {
+ gitCredential = GitCredential(
+ credential: GitCredential.Credential.ssh(
+ userName: username,
+ password: Utils.getPasswordFromKeychain(name: "gitSSHPrivateKeyPassphrase") ?? "",
+ publicKeyFile: Globals.gitSSHPublicKeyURL,
+ privateKeyFile: Globals.gitSSHPrivateKeyURL,
+ requestSSHKeyPassword: self.requestGitPassword
)
- }
- let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
- dispatchQueue.async {
- do {
- try self.passwordStore.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
- credential: gitCredential,
- transferProgressBlock:{ (git_transfer_progress, stop) in
- DispatchQueue.main.async {
- SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Clone Remote Repository")
- }
- },
- checkoutProgressBlock: { (path, completedSteps, totalSteps) in
- DispatchQueue.main.async {
- SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
- }
- })
- DispatchQueue.main.async {
- Defaults[.gitURL] = URL(string: gitRepostiroyURL)
- Defaults[.gitUsername] = username
- Defaults[.gitAuthenticationMethod] = auth
- Defaults[.gitPasswordAttempts] = 0
- self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults[.gitURL]?.host
- SVProgressHUD.showSuccess(withStatus: "Done")
- SVProgressHUD.dismiss(withDelay: 1)
- }
- } catch {
- DispatchQueue.main.async {
- Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
- }
+ )
+ }
+ let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
+ dispatchQueue.async {
+ do {
+ try self.passwordStore.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
+ credential: gitCredential,
+ transferProgressBlock:{ (git_transfer_progress, stop) in
+ DispatchQueue.main.async {
+ SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Clone Remote Repository")
+ }
+ },
+ checkoutProgressBlock: { (path, completedSteps, totalSteps) in
+ DispatchQueue.main.async {
+ SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
+ }
+ })
+ DispatchQueue.main.async {
+ Defaults[.gitURL] = URL(string: gitRepostiroyURL)
+ Defaults[.gitUsername] = username
+ Defaults[.gitAuthenticationMethod] = auth
+ Defaults[.gitPasswordAttempts] = 0
+ self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults[.gitURL]?.host
+ SVProgressHUD.showSuccess(withStatus: "Done")
+ SVProgressHUD.dismiss(withDelay: 1)
+ }
+ } catch {
+ DispatchQueue.main.async {
+ Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
-
}
+
}
}
}