From dd36e8795960aa12cc19fd1e61cc49c66fa27fd8 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Thu, 2 Feb 2017 15:02:57 +0800 Subject: [PATCH] fix bugs in the first startup --- pass/PasswordStore.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pass/PasswordStore.swift b/pass/PasswordStore.swift index 624de27..99343b5 100644 --- a/pass/PasswordStore.swift +++ b/pass/PasswordStore.swift @@ -43,7 +43,7 @@ class PasswordStore { let storeURL = URL(fileURLWithPath: "\(Globals.shared.documentPath)/password-store") var storeRepository: GTRepository? - var gitCredential: GitCredential + var gitCredential: GitCredential? let pgp: ObjectivePGP = ObjectivePGP() @@ -61,8 +61,10 @@ class PasswordStore { } if Defaults[.gitRepositoryAuthenticationMethod] == "Password" { gitCredential = GitCredential(credential: GitCredential.Credential.http(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositoryPassword])) - } else { + } else if Defaults[.gitRepositoryAuthenticationMethod] == "SSH Key"{ gitCredential = GitCredential(credential: GitCredential.Credential.ssh(userName: Defaults[.gitRepositoryUsername], password: Defaults[.gitRepositorySSHPrivateKeyPassphrase]!, publicKeyFile: Globals.shared.sshPublicKeyPath, privateKeyFile: Globals.shared.sshPrivateKeyPath)) + } else { + gitCredential = nil } } @@ -120,7 +122,7 @@ class PasswordStore { print("pullRepoisitory") do { print("start pulling...") - let credentialProvider = try gitCredential.credentialProvider() + let credentialProvider = try gitCredential!.credentialProvider() let options: [String: Any] = [ GTRepositoryRemoteOptionsCredentialProvider: credentialProvider ]