Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 8aba8c4

Browse files
authored
Handle user canceled "error" for Google SDK-less flow (#762)
2 parents cc49822 + 0a6af30 commit 8aba8c4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Demo/AuthenticatorDemo/ViewController+WordPressAuthenticator.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AuthenticationServices
12
import WebKit
23
import WordPressAuthenticator
34
import WordPressKit
@@ -96,6 +97,11 @@ extension ViewController {
9697
)
9798
} catch let error as OAuthError {
9899
presentAlert(title: "", message: error.errorDescription, onDismiss: {})
100+
} catch let error as ASWebAuthenticationSessionError
101+
where error.code == ASWebAuthenticationSessionError.canceledLogin {
102+
// In a production app, the UX would be better if we didn't present an alert.
103+
// But here, it's useful to show it to make the error handling visible for reference.
104+
presentAlert(title: "", message: "User cancelled", onDismiss: {})
99105
} catch {
100106
fatalError("Caught an error that was not of the expected `OAuthError` type: \(error)")
101107
}

WordPressAuthenticator/Unified Auth/View Related/Google/GoogleAuthViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import SVProgressHUD
2+
13
/// View controller that handles the google authentication flow
24
///
35
class GoogleAuthViewController: LoginViewController {
@@ -142,6 +144,7 @@ extension GoogleAuthViewController: GoogleAuthenticatorDelegate {
142144
}
143145

144146
func googleAuthCancelled() {
147+
SVProgressHUD.dismiss()
145148
navigationController?.popViewController(animated: true)
146149
}
147150

0 commit comments

Comments
 (0)