mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
Fixing updating attribute value
Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
parent
5436f9781c
commit
a8997c364f
@ -17,7 +17,7 @@ export const TextAreaComponent = (props: UserProfileFieldProps) => {
|
||||
rows={attribute.annotations?.["inputTypeRows"] as number}
|
||||
readOnly={attribute.readOnly}
|
||||
isRequired={isRequired}
|
||||
value={attribute.defaultValue}
|
||||
defaultValue={attribute.defaultValue}
|
||||
/>
|
||||
</UserProfileGroup>
|
||||
);
|
||||
|
||||
@ -31,7 +31,7 @@ export const TextComponent = (props: UserProfileFieldProps) => {
|
||||
}
|
||||
isDisabled={attribute.readOnly}
|
||||
isRequired={isRequired}
|
||||
value={attribute.defaultValue}
|
||||
defaultValue={attribute.defaultValue}
|
||||
{...form.register(fieldName(attribute.name))}
|
||||
/>
|
||||
</UserProfileGroup>
|
||||
|
||||
@ -410,23 +410,20 @@ public class DefaultAttributes extends HashMap<String, List<String>> implements
|
||||
}
|
||||
}
|
||||
|
||||
// the profile should always hold all attributes defined in the config and set default value if needed
|
||||
// the profile should always hold all attributes defined in the config
|
||||
for (String attributeName : metadataByAttribute.keySet()) {
|
||||
if (!isSupportedAttribute(attributeName) || newAttributes.containsKey(attributeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AttributeMetadata metadata = metadataByAttribute.get(attributeName);
|
||||
List<String> values = EMPTY_VALUE;
|
||||
if (metadata.getDefaultValue() != null) {
|
||||
values = Collections.singletonList(metadata.getDefaultValue());
|
||||
}
|
||||
AttributeMetadata metadata = metadataByAttribute.get(attributeName);
|
||||
|
||||
if (user != null && isIncludeAttributeIfNotProvided(metadata)) {
|
||||
values = normalizeAttributeValues(attributeName, user.getAttributes().getOrDefault(attributeName, EMPTY_VALUE));
|
||||
values = user.getAttributes().getOrDefault(attributeName, EMPTY_VALUE);
|
||||
}
|
||||
|
||||
newAttributes.put(attributeName, values);
|
||||
newAttributes.put(attributeName, normalizeAttributeValues(attributeName, values));
|
||||
}
|
||||
|
||||
if (user != null) {
|
||||
@ -471,10 +468,16 @@ public class DefaultAttributes extends HashMap<String, List<String>> implements
|
||||
if (value instanceof String) {
|
||||
values = Collections.singletonList((String) value);
|
||||
} else {
|
||||
values = (List<String>) value;
|
||||
values = value == null ? EMPTY_VALUE : (List<String>) value;
|
||||
}
|
||||
|
||||
Stream<String> valuesStream = Optional.ofNullable(values).orElse(EMPTY_VALUE).stream().filter(Objects::nonNull);
|
||||
AttributeMetadata metadata = metadataByAttribute.get(name);
|
||||
|
||||
if (values.isEmpty() && metadata != null && metadata.getDefaultValue() != null) {
|
||||
values = List.of(metadata.getDefaultValue());
|
||||
}
|
||||
|
||||
Stream<String> valuesStream = values.stream().filter(Objects::nonNull);
|
||||
|
||||
// do not normalize the username if a federated user because we need to respect the format from the external identity store
|
||||
if ((UserModel.USERNAME.equals(name) && !isFederated()) || UserModel.EMAIL.equals(name)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user