user displayname fall's back to username
This commit is contained in:
parent
e21c04c533
commit
ad8be9cbb7
1 changed files with 6 additions and 6 deletions
|
@ -12,6 +12,7 @@ import com.unboundid.scim2.common.types.Meta;
|
||||||
import com.unboundid.scim2.common.types.Role;
|
import com.unboundid.scim2.common.types.Role;
|
||||||
import com.unboundid.scim2.common.types.UserResource;
|
import com.unboundid.scim2.common.types.UserResource;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
|
@ -85,13 +86,12 @@ public class UserAdapter extends Adapter<UserModel, UserResource> {
|
||||||
public void apply(UserModel user) {
|
public void apply(UserModel user) {
|
||||||
setId(user.getId());
|
setId(user.getId());
|
||||||
setUsername(user.getUsername());
|
setUsername(user.getUsername());
|
||||||
if (user.getFirstName() != null && user.getLastName() != null) {
|
var displayName = String.format("%s %s", StringUtils.defaultString(user.getFirstName()),
|
||||||
setDisplayName(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
StringUtils.defaultString(user.getLastName())).trim();
|
||||||
} else if (user.getFirstName() != null) {
|
if (StringUtils.isEmpty(displayName)) {
|
||||||
setDisplayName(user.getFirstName());
|
displayName = user.getUsername();
|
||||||
} else if (user.getLastName() != null) {
|
|
||||||
setDisplayName(user.getLastName());
|
|
||||||
}
|
}
|
||||||
|
setDisplayName(displayName);
|
||||||
setEmail(user.getEmail());
|
setEmail(user.getEmail());
|
||||||
setActive(user.isEnabled());
|
setActive(user.isEnabled());
|
||||||
var rolesSet = new HashSet<String>();
|
var rolesSet = new HashSet<String>();
|
||||||
|
|
Loading…
Reference in a new issue