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
|
|
@ -8,43 +8,6 @@
|
|||
|
||||
import Foundation
|
||||
import ObjectiveGit
|
||||
import SVProgressHUD
|
||||
|
||||
public func requestCredentialPassword(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
|
||||
}
|
||||
|
||||
public struct GitCredential {
|
||||
private var credential: Credential
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue