mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-04-26 14:57:37 +00:00
Try to improve auth error messages
This commit is contained in:
parent
a04bfb39d0
commit
58cddb88f6
2 changed files with 21 additions and 9 deletions
|
|
@ -129,7 +129,7 @@ public class Client {
|
||||||
case 400, 401:
|
case 400, 401:
|
||||||
throw AuthenticationError.incorrectSecurityCode
|
throw AuthenticationError.incorrectSecurityCode
|
||||||
case let code:
|
case let code:
|
||||||
throw AuthenticationError.badStatusCode(code, data, urlResponse)
|
throw AuthenticationError.badStatusCode(statusCode: code, data: data, response: urlResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.flatMap { (data, response) -> AnyPublisher<AuthenticationState, Error> in
|
.flatMap { (data, response) -> AnyPublisher<AuthenticationState, Error> in
|
||||||
|
|
@ -180,20 +180,31 @@ public enum AuthenticationError: Swift.Error, LocalizedError, Equatable {
|
||||||
case appleIDAndPrivacyAcknowledgementRequired
|
case appleIDAndPrivacyAcknowledgementRequired
|
||||||
case accountUsesTwoStepAuthentication
|
case accountUsesTwoStepAuthentication
|
||||||
case accountUsesUnknownAuthenticationKind(String?)
|
case accountUsesUnknownAuthenticationKind(String?)
|
||||||
case badStatusCode(Int, Data, HTTPURLResponse)
|
case badStatusCode(statusCode: Int, data: Data, response: HTTPURLResponse)
|
||||||
|
|
||||||
public var errorDescription: String? {
|
public var errorDescription: String? {
|
||||||
switch self {
|
switch self {
|
||||||
case .invalidUsernameOrPassword(let username):
|
case .invalidSession:
|
||||||
return "Invalid username and password combination. Attempted to sign in with username \(username)."
|
return "Your authentication session is invalid. Try signing in again."
|
||||||
|
case .invalidUsernameOrPassword:
|
||||||
|
return "Invalid username and password combination."
|
||||||
|
case .incorrectSecurityCode:
|
||||||
|
return "The code that was entered is incorrect."
|
||||||
|
case let .unexpectedSignInResponse(statusCode, message):
|
||||||
|
return """
|
||||||
|
Received an unexpected sign in response. If you continue to have problems, please submit a bug report in the Help menu and include the following information:
|
||||||
|
|
||||||
|
Status code: \(statusCode)
|
||||||
|
\(message != nil ? ("Message: " + message!) : "")
|
||||||
|
"""
|
||||||
case .appleIDAndPrivacyAcknowledgementRequired:
|
case .appleIDAndPrivacyAcknowledgementRequired:
|
||||||
return "You must sign in to https://appstoreconnect.apple.com and acknowledge the Apple ID & Privacy agreement."
|
return "You must sign in to https://appstoreconnect.apple.com and acknowledge the Apple ID & Privacy agreement."
|
||||||
case .accountUsesTwoStepAuthentication:
|
case .accountUsesTwoStepAuthentication:
|
||||||
return "Received a response from Apple that indicates this account has two-step authentication enabled. xcodes currently only supports the newer two-factor authentication, though. Please consider upgrading to two-factor authentication, or open an issue on GitHub explaining why this isn't an option for you here: https://github.com/RobotsAndPencils/xcodes/issues/new"
|
return "Received a response from Apple that indicates this account has two-step authentication enabled. xcodes currently only supports the newer two-factor authentication, though. Please consider upgrading to two-factor authentication, or explain why this isn't an option for you by making a new feature request in the Help menu."
|
||||||
case .accountUsesUnknownAuthenticationKind:
|
case .accountUsesUnknownAuthenticationKind:
|
||||||
return "Received a response from Apple that indicates this account has two-step or two-factor authentication enabled, but xcodes is unsure how to handle this response:"
|
return "Received a response from Apple that indicates this account has two-step or two-factor authentication enabled, but xcodes is unsure how to handle this response. If you continue to have problems, please submit a bug report in the Help menu."
|
||||||
default:
|
case let .badStatusCode(statusCode, _, _):
|
||||||
return String(describing: self)
|
return "Received an unexpected status code: \(statusCode). If you continue to have problems, please submit a bug report in the Help menu."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import LegibleError
|
||||||
import KeychainAccess
|
import KeychainAccess
|
||||||
import Path
|
import Path
|
||||||
import Version
|
import Version
|
||||||
|
import os.log
|
||||||
|
|
||||||
class AppState: ObservableObject {
|
class AppState: ObservableObject {
|
||||||
private let client = AppleAPI.Client()
|
private let client = AppleAPI.Client()
|
||||||
|
|
@ -181,7 +182,7 @@ class AppState: ObservableObject {
|
||||||
try? Current.keychain.remove(username)
|
try? Current.keychain.remove(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This error message is not user friendly... need to extract some meaningful data in the different cases
|
Logger.appState.error("Authentication error: \(error.legibleDescription)")
|
||||||
self.authError = error
|
self.authError = error
|
||||||
case .finished:
|
case .finished:
|
||||||
switch self.authenticationState {
|
switch self.authenticationState {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue