Skip to content

Commit 16ec00a

Browse files
committed
fix: refactor URL parameter handling in authenticateURI method for improved readability and maintainability
1 parent ce06875 commit 16ec00a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Project/Sources/Classes/OAuth2Provider.4dm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -925,35 +925,35 @@ Function get authenticateURI() : Text
925925
var $scope : Text:=This.scope
926926
var $state : Text:=This.state
927927
var $redirectURI : Text:=This.redirectURI
928-
var $urlParams : Text
928+
var $urlParams : cs.URL:=cs.URL.new()
929929

930-
$urlParams:="?client_id="+This.clientId
931-
$urlParams+="&response_type=code"
930+
$urlParams.addQueryParameter("client_id"; This.clientId)
931+
$urlParams.addQueryParameter("response_type"; "code")
932932
If (Length(String($scope))>0)
933-
$urlParams+="&scope="+cs.Tools.me.urlEncode($scope)
933+
$urlParams.addQueryParameter("scope"; cs.Tools.me.urlEncode($scope))
934934
End if
935-
$urlParams+="&state="+String($state)
936-
$urlParams+="&response_mode=query"
937-
$urlParams+="&redirect_uri="+cs.Tools.me.urlEncode($redirectURI)
935+
$urlParams.addQueryParameter("state"; String($state))
936+
$urlParams.addQueryParameter("response_mode"; "query")
937+
$urlParams.addQueryParameter("redirect_uri"; cs.Tools.me.urlEncode($redirectURI))
938938
If (This.PKCEEnabled)
939-
$urlParams+="&code_challenge="+This._generateCodeChallenge(This.codeVerifier)
940-
$urlParams+="&code_challenge_method="+String(This.PKCEMethod)
939+
$urlParams.addQueryParameter("code_challenge"; This._generateCodeChallenge(This.codeVerifier))
940+
$urlParams.addQueryParameter("code_challenge_method"; String(This.PKCEMethod))
941941
Else
942942
If (Length(String(This.accessType))>0)
943-
$urlParams+="&access_type="+This.accessType
943+
$urlParams.addQueryParameter("access_type"; This.accessType)
944944
End if
945945
If (Length(String(This.loginHint))>0)
946-
$urlParams+="&login_hint="+This.loginHint
946+
$urlParams.addQueryParameter("login_hint"; This.loginHint)
947947
End if
948948
If (Length(String(This.prompt))>0)
949-
$urlParams+="&prompt="+This.prompt
949+
$urlParams.addQueryParameter("prompt"; This.prompt)
950950
End if
951951
End if
952952
If (Length(String(This.nonce))>0)
953-
$urlParams+="&nonce="+This.nonce
953+
$urlParams.addQueryParameter("nonce"; This.nonce)
954954
End if
955955

956-
$authenticateURI+=$urlParams
956+
$authenticateURI+=$urlParams.getQueryString()
957957
End if
958958

959959
return $authenticateURI

0 commit comments

Comments
 (0)