complete SSH Key authentication

This commit is contained in:
Bob Sun 2017-01-31 22:00:50 +08:00
parent 7a3f05701b
commit 62e2a7fe89
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 15 additions and 5 deletions

View file

@ -23,7 +23,7 @@ class SettingsTableViewController: UITableViewController {
let gitRepostiroyURL = controller.gitRepositoryURLTextField.text!
let username = controller.usernameTextField.text!
let password = controller.passwordTextField.text!
let auth = controller.authenticationTableViewCell.detailTextLabel!.text!
let auth = controller.authenticationMethod
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
@ -34,7 +34,12 @@ class SettingsTableViewController: UITableViewController {
if Defaults[.gitRepositoryURL] == nil || gitRepostiroyURL != Defaults[.gitRepositoryURL]!.absoluteString {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.show(withStatus: "Prepare Repository")
let gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password))
var gitCredential: GitCredential
if Defaults[.gitRepositoryAuthenticationMethod] == "Password" {
gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: username, password: password))
} else {
gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: username, password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Defaults[.gitRepositorySSHPublicKeyURL]!, privateKeyFile: Defaults[.gitRepositorySSHPrivateKeyURL]!))
}
DispatchQueue.global(qos: .userInitiated).async {
let ret = PasswordStore.shared.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,