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