Skip to content

Commit

Permalink
Fix crash when programatically cancelling auth flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tagavari committed Oct 18, 2022
1 parent e8e1845 commit f324720
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions AirMessage/Controllers/AccountConnectViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ class AccountConnectViewController: NSViewController {
//Surface errors to the user
if let error = error as? NSError {
//Don't show cancellation errors
if error.domain == OIDGeneralErrorDomain
&& (error.code == OIDErrorCode.userCanceledAuthorizationFlow.rawValue
|| error.code == OIDErrorCode.programCanceledAuthorizationFlow.rawValue) {
self.dismiss(self)
if error.domain == OIDGeneralErrorDomain {
if error.code == OIDErrorCode.userCanceledAuthorizationFlow.rawValue {
//If the user cancelled, dismiss the view controller
self.dismiss(self)
} else if error.code == OIDErrorCode.programCanceledAuthorizationFlow.rawValue {
//If we cancelled (for example, the user closed the window), do nothing
return
}
} else {
//Present the error to the user
self.showError(message: error.localizedDescription, showReconnect: false)
}

return
}

Expand Down

0 comments on commit f324720

Please sign in to comment.