Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): add organization resource in generateSignInUri method #222

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import io.logto.sdk.core.constant.GrantType
import io.logto.sdk.core.constant.PromptValue
import io.logto.sdk.core.constant.QueryKey
import io.logto.sdk.core.constant.ReservedResource
import io.logto.sdk.core.constant.ResponseType
import io.logto.sdk.core.constant.UserScope
import io.logto.sdk.core.exception.UriConstructionException
import io.logto.sdk.core.http.HttpCompletion
import io.logto.sdk.core.http.HttpEmptyCompletion
Expand Down Expand Up @@ -39,8 +41,19 @@
addQueryParameter(QueryKey.STATE, state)
addQueryParameter(QueryKey.REDIRECT_URI, redirectUri)
addQueryParameter(QueryKey.RESPONSE_TYPE, ResponseType.CODE)
addQueryParameter(QueryKey.SCOPE, ScopeUtils.withDefaultScopes(scopes).joinToString(" "))
resources?.let { for (value in it) { addQueryParameter(QueryKey.RESOURCE, value) } }

val usedScopes = ScopeUtils.withDefaultScopes(scopes)
addQueryParameter(QueryKey.SCOPE, usedScopes.joinToString(" "))

val usedResources = resources.orEmpty()
for (value in usedResources) { addQueryParameter(QueryKey.RESOURCE, value) }
if (
usedScopes.contains(UserScope.ORGANIZATIONS) &&
!usedResources.contains(ReservedResource.ORGANIZATION)
) {
addQueryParameter(QueryKey.RESOURCE, ReservedResource.ORGANIZATION)

Check warning on line 54 in kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/Core.kt

View check run for this annotation

Codecov / codecov/patch

kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/Core.kt#L54

Added line #L54 was not covered by tests
}

addQueryParameter(QueryKey.PROMPT, prompt ?: PromptValue.CONSENT)
}.build().toString()
}
Expand Down
Loading