Skip to content

Commit

Permalink
using buildMap from kotlin collections
Browse files Browse the repository at this point in the history
  • Loading branch information
lalwani committed Jul 15, 2024
1 parent 6d907bf commit b4449de
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,19 @@ class AuthProvider(
?: throw AuthException.ServerError("Bad response ${response.code()}")
} ?: PARResponse("", "")

private fun getQueryParams(parResponse: PARResponse) =
private fun getQueryParams(parResponse: PARResponse) = buildMap {
when (authContext.authType) {
AuthType.AuthCode ->
mutableMapOf<String, String>().apply {
parResponse.requestUri.takeIf { it.isNotEmpty() }?.let { put(REQUEST_URI, it) }
}
AuthType.AuthCode -> {
parResponse.requestUri.takeIf { it.isNotEmpty() }?.let { put(REQUEST_URI, it) }
}
is AuthType.PKCE -> {
val codeChallenge = codeVerifierGenerator.generateCodeChallenge(verifier)
mutableMapOf<String, String>().apply {
parResponse.requestUri.takeIf { it.isNotEmpty() }?.let { put(REQUEST_URI, it) }
put(CODE_CHALLENGE_PARAM, codeChallenge)
put(UriConfig.CODE_CHALLENGE_METHOD, UriConfig.CODE_CHALLENGE_METHOD_VAL)
}
parResponse.requestUri.takeIf { it.isNotEmpty() }?.let { put(REQUEST_URI, it) }
put(CODE_CHALLENGE_PARAM, codeChallenge)
put(UriConfig.CODE_CHALLENGE_METHOD, UriConfig.CODE_CHALLENGE_METHOD_VAL)
}
}
}

override fun handleAuthCode(authCode: String) {
ssoLink.handleAuthCode(authCode)
Expand Down

0 comments on commit b4449de

Please sign in to comment.