diff --git a/Demo/AuthenticatorDemo/ViewController+WordPressAuthenticator.swift b/Demo/AuthenticatorDemo/ViewController+WordPressAuthenticator.swift index 5564f63d8..aa797df62 100644 --- a/Demo/AuthenticatorDemo/ViewController+WordPressAuthenticator.swift +++ b/Demo/AuthenticatorDemo/ViewController+WordPressAuthenticator.swift @@ -1,3 +1,4 @@ +import AuthenticationServices import WebKit import WordPressAuthenticator import WordPressKit @@ -96,6 +97,11 @@ extension ViewController { ) } catch let error as OAuthError { presentAlert(title: "❌", message: error.errorDescription, onDismiss: {}) + } catch let error as ASWebAuthenticationSessionError + where error.code == ASWebAuthenticationSessionError.canceledLogin { + // In a production app, the UX would be better if we didn't present an alert. + // But here, it's useful to show it to make the error handling visible for reference. + presentAlert(title: "", message: "User cancelled", onDismiss: {}) } catch { fatalError("Caught an error that was not of the expected `OAuthError` type: \(error)") } diff --git a/WordPressAuthenticator/Unified Auth/View Related/Google/GoogleAuthViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Google/GoogleAuthViewController.swift index 8f821866b..05e1e2575 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Google/GoogleAuthViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Google/GoogleAuthViewController.swift @@ -1,3 +1,5 @@ +import SVProgressHUD + /// View controller that handles the google authentication flow /// class GoogleAuthViewController: LoginViewController { @@ -142,6 +144,7 @@ extension GoogleAuthViewController: GoogleAuthenticatorDelegate { } func googleAuthCancelled() { + SVProgressHUD.dismiss() navigationController?.popViewController(animated: true) }