8000 Load declarative component instead of any user profile component by statist32 · Pull Request #40827 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Load declarative component instead of any user profile component #40827

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ public UPConfig getConfiguration() {
@Override
public void setConfiguration(UPConfig configuration) {
RealmModel realm = session.getContext().getRealm();
Optional<ComponentModel> optionalComponent = realm.getComponentsStream(realm.getId(), UserProfileProvider.class.getName()).findAny();
Optional<ComponentModel> optionalComponent = getComponentModel();

// Avoid creating componentModel and then removing it right away
if (!optionalComponent.isPresent() && configuration == null) return;
if (optionalComponent.isEmpty() && configuration == null) {
return;
}

ComponentModel component = optionalComponent.isPresent() ? optionalComponent.get() : createComponentModel();
ComponentModel component = optionalComponent.orElseGet(this::createComponentModel);

removeConfigJsonFromComponentModel(component);

Expand All @@ -238,7 +240,7 @@ public void setConfiguration(UPConfig configuration) {

private Optional<ComponentModel> getComponentModel() {
RealmModel realm = session.getContext().getRealm();
return realm.getComponentsStream(realm.getId(), UserProfileProvider.class.getName()).findAny();
return realm.getComponentsStream(realm.getId(), UserProfileProvider.class.getName()).filter(componentModel -> componentModel.getProviderId().equals(providerId)).findFirst();
}

/**
Expand Down
Loading
0