Skip to content

Commit

Permalink
ios: add a few additional logs on rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Oberwasserlechner committed Aug 27, 2020
1 parent a4d59ff commit ac30506
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ public class OAuth2ClientPlugin: CAPPlugin {
let jsonObj = try JSONSerialization.jsonObject(with: tokenSuccess.response!.data, options: []) as! JSObject
call.resolve(jsonObj)
} catch {
self.log("Invalid json in renew access token response \(error.localizedDescription)")
call.reject(self.ERR_GENERAL)
}
case .failure(let error):
switch error {
case .cancelled, .accessDenied(_, _):
call.reject(SharedConstants.ERR_USER_CANCELLED)
case .stateNotEqual( _, _):
self.log("The given state does not match the one in the respond!")
call.reject(self.ERR_STATES_NOT_MATCH)
default:
self.log("Authorization failed with \(error.localizedDescription)");
Expand Down Expand Up @@ -187,6 +189,7 @@ public class OAuth2ClientPlugin: CAPPlugin {
jsonObj.updateValue(accessToken, forKey: self.JSON_KEY_ACCESS_TOKEN)
call.resolve(jsonObj)
} else {
self.log("Invalid json in resource response. '\(response.data)'")
call.reject(self.ERR_GENERAL)
}
case .failure(let error):
Expand Down Expand Up @@ -309,6 +312,7 @@ public class OAuth2ClientPlugin: CAPPlugin {
if success {
call.resolve();
} else {
self.log("Custom handler logout failed!")
call.reject(self.ERR_CUSTOM_HANDLER_LOGOUT)
}
} else {
Expand Down Expand Up @@ -356,6 +360,7 @@ public class OAuth2ClientPlugin: CAPPlugin {
let jsonObj = try JSONSerialization.jsonObject(with: response!.data, options: []) as! JSObject
call.resolve(jsonObj)
} catch {
self.log("Invalid json in response \(error.localizedDescription)")
call.reject(self.ERR_GENERAL)
}
}
Expand All @@ -364,6 +369,7 @@ public class OAuth2ClientPlugin: CAPPlugin {
case .cancelled, .accessDenied(_, _):
call.reject(SharedConstants.ERR_USER_CANCELLED)
case .stateNotEqual(_, _):
self.log("The given state does not match the one in the respond!")
call.reject(self.ERR_STATES_NOT_MATCH)
default:
self.log("Authorization failed with \(error.localizedDescription)");
Expand Down Expand Up @@ -552,6 +558,7 @@ extension OAuth2ClientPlugin: ASAuthorizationControllerDelegate {
] as [String : Any]
self.savedPluginCall?.resolve(result as PluginResultData)
default:
self.log("SIWA: Authorization failed!")
self.savedPluginCall?.reject(self.ERR_AUTHORIZATION_FAILED)
}
}
Expand All @@ -567,7 +574,7 @@ extension OAuth2ClientPlugin: ASAuthorizationControllerDelegate {
self.savedPluginCall?.reject(SharedConstants.ERR_USER_CANCELLED)
case .unknown:
self.log("SIWA: Error.unknown.")
self.savedPluginCall?.reject(self.ERR_GENERAL)
self.savedPluginCall?.reject(SharedConstants.ERR_USER_CANCELLED)
case .invalidResponse:
self.log("SIWA: Error.invalidResponse")
self.savedPluginCall?.reject(self.ERR_AUTHORIZATION_FAILED)
Expand Down

0 comments on commit ac30506

Please sign in to comment.