Move the request credential function into one file
This commit is contained in:
parent
2f3e51947a
commit
efdc45ea89
5 changed files with 53 additions and 39 deletions
|
|
@ -286,7 +286,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
private func requestCredentialPassword(credential: GitCredential.Credential, lastPassword: String?) -> String? {
|
||||
return passKit.requestCredentialPassword(credential: credential, lastPassword: lastPassword, controller: self)
|
||||
return requestGitCredentialPassword(credential: credential, lastPassword: lastPassword, controller: self)
|
||||
}
|
||||
|
||||
private func updateAuthenticationMethodCheckView(for method: GitAuthenticationMethod) {
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
}
|
||||
|
||||
private func requestCredentialPassword(credential: GitCredential.Credential, lastPassword: String?) -> String? {
|
||||
return passKit.requestCredentialPassword(credential: credential, lastPassword: lastPassword, controller: self)
|
||||
return requestGitCredentialPassword(credential: credential, lastPassword: lastPassword, controller: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
47
pass/Helpers/GitCredentialPassword.swift
Normal file
47
pass/Helpers/GitCredentialPassword.swift
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// GitCredentialPassword.swift
|
||||
// pass
|
||||
//
|
||||
// Created by Sun, Mingshen on 11/30/19.
|
||||
// Copyright © 2019 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SVProgressHUD
|
||||
import passKit
|
||||
|
||||
public func requestGitCredentialPassword(credential: GitCredential.Credential,
|
||||
lastPassword: String?,
|
||||
controller: UIViewController) -> String? {
|
||||
let sem = DispatchSemaphore(value: 0)
|
||||
var password: String?
|
||||
let message: String = {
|
||||
switch credential {
|
||||
case .http:
|
||||
return "FillInGitAccountPassword.".localize()
|
||||
case .ssh:
|
||||
return "FillInSshKeyPassphrase.".localize()
|
||||
}
|
||||
}()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
SVProgressHUD.dismiss()
|
||||
let alert = UIAlertController(title: "Password".localize(), message: message, preferredStyle: .alert)
|
||||
alert.addTextField() {
|
||||
$0.text = lastPassword ?? ""
|
||||
$0.isSecureTextEntry = true
|
||||
}
|
||||
alert.addAction(UIAlertAction(title: "Ok".localize(), style: .default) { _ in
|
||||
password = alert.textFields?.first?.text
|
||||
sem.signal()
|
||||
})
|
||||
alert.addAction(UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in
|
||||
password = nil
|
||||
sem.signal()
|
||||
})
|
||||
controller.present(alert, animated: true)
|
||||
}
|
||||
|
||||
let _ = sem.wait(timeout: .distantFuture)
|
||||
return password
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue