Don't display error message on login cancellation
This commit is contained in:
parent
7e90fe2401
commit
c6d158a8a3
|
@ -93,7 +93,11 @@ class OnboardingViewController: UINavigationController {
|
|||
return try await withCheckedThrowingContinuation({ continuation in
|
||||
self.authenticationSession = ASWebAuthenticationSession(url: authorizeURL, callbackURLScheme: "tusker", completionHandler: { url, error in
|
||||
if let error = error {
|
||||
if (error as? ASWebAuthenticationSessionError)?.code == .canceledLogin {
|
||||
continuation.resume(throwing: Error.cancelled)
|
||||
} else {
|
||||
continuation.resume(throwing: Error.authenticationSessionError(error))
|
||||
}
|
||||
} else if let url = url,
|
||||
let components = URLComponents(url: url, resolvingAgainstBaseURL: true),
|
||||
let item = components.queryItems?.first(where: { $0.name == "code" }),
|
||||
|
@ -114,6 +118,7 @@ class OnboardingViewController: UINavigationController {
|
|||
|
||||
extension OnboardingViewController {
|
||||
enum Error: Swift.Error {
|
||||
case cancelled
|
||||
case registeringApp(Swift.Error)
|
||||
case authenticationSessionError(Swift.Error)
|
||||
case noAuthorizationCode
|
||||
|
@ -122,6 +127,8 @@ extension OnboardingViewController {
|
|||
|
||||
var localizedDescription: String {
|
||||
switch self {
|
||||
case .cancelled:
|
||||
return "Login Cancelled"
|
||||
case .registeringApp(let error):
|
||||
return "Couldn't register app: \(error)"
|
||||
case .authenticationSessionError(let error):
|
||||
|
@ -142,6 +149,8 @@ extension OnboardingViewController: InstanceSelectorTableViewControllerDelegate
|
|||
Task {
|
||||
do {
|
||||
try await self.tryLoginTo(instanceURL: instanceURL)
|
||||
} catch Error.cancelled {
|
||||
// no-op, don't show an error message
|
||||
} catch let error as Error {
|
||||
let alert = UIAlertController(title: "Error Logging In", message: error.localizedDescription, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "Ok", style: .default))
|
||||
|
|
Loading…
Reference in New Issue