Skip to content

Commit

Permalink
Fix JetBrains authorization (#599)
Browse files Browse the repository at this point in the history
^ALTAPPS-911 Needs testing
  • Loading branch information
XanderZhu authored Jul 26, 2023
1 parent 52dfa3c commit 5201096
Showing 1 changed file with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,23 @@ class AuthSocialWebViewClient(
request?.url?.let { url ->
val urlString = url.toString()
if (urlString.startsWith("https://${networkEndpointConfigInfo.host}/oauth?")) {
val message = try {
val codeQueryParameter = url.getQueryParameter(CodeParameter)
if (codeQueryParameter != null) {
AuthSocialWebViewFeature.Message.AuthCodeSuccess(
codeQueryParameter,
socialAuthProvider
try {
url.getQueryParameter(CodeParameter)?.let { codeQueryParameter ->
onNewMessage(
AuthSocialWebViewFeature.Message.AuthCodeSuccess(
codeQueryParameter,
socialAuthProvider
)
)
} else {
}
} catch (e: UnsupportedOperationException) {
onNewMessage(
AuthSocialWebViewFeature.Message.AuthCodeFailure(
socialError = AuthSocialError.CONNECTION_PROBLEM,
originalError = IllegalStateException("No code query parameter in url")
originalError = e
)
}
} catch (e: UnsupportedOperationException) {
AuthSocialWebViewFeature.Message.AuthCodeFailure(
socialError = AuthSocialError.CONNECTION_PROBLEM,
originalError = e
)
}
onNewMessage(message)
}
}
return false
Expand All @@ -56,12 +53,18 @@ class AuthSocialWebViewClient(
request: WebResourceRequest?,
error: WebResourceError?
) {
onNewMessage(
AuthSocialWebViewFeature.Message.AuthCodeFailure(
socialError = AuthSocialError.CONNECTION_PROBLEM,
originalError = if (error != null) Exception(error.description.toString()) else null
if (request?.isForMainFrame == true) {
onNewMessage(
AuthSocialWebViewFeature.Message.AuthCodeFailure(
socialError = AuthSocialError.CONNECTION_PROBLEM,
originalError = if (error != null) Exception(
"Error code=${error.errorCode}, description=${error.description}"
) else {
null
}
)
)
)
}
}

override fun onPageFinished(view: WebView?, url: String?) {
Expand Down

0 comments on commit 5201096

Please sign in to comment.