From 43ff63e01de22d432c89025674baaea8b04e4f95 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Mon, 20 May 2019 01:26:53 +0800 Subject: [PATCH] Do no prompt repeatedly for the SSH passphrase --- passKit/Models/GitCredential.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/passKit/Models/GitCredential.swift b/passKit/Models/GitCredential.swift index 6dd046f..8a7d6a0 100644 --- a/passKit/Models/GitCredential.swift +++ b/passKit/Models/GitCredential.swift @@ -31,6 +31,10 @@ public struct GitCredential { switch self.credential { case let .http(userName): + if attempts > 3 { + // After too many failures (say six), the error message "failed to authenticate ssh session" might be confusing. + return nil + } var lastPassword = self.passwordStore.gitPassword if lastPassword == nil || attempts != 0 { if let requestedPassword = requestGitPassword(self.credential, lastPassword) { @@ -45,7 +49,10 @@ public struct GitCredential { attempts += 1 credential = try? GTCredential(userName: userName, password: lastPassword!) case let .ssh(userName, privateKeyFile): - // remarks: in fact, attempts > 1 never happens even with the wrong passphrase + if attempts > 0 { + // The passphrase seems correct, but the previous authentification failed. + return nil + } var lastPassword = self.passwordStore.gitSSHPrivateKeyPassphrase if lastPassword == nil || attempts != 0 { if let requestedPassword = requestGitPassword(self.credential, lastPassword) {