Merge pull request #156 from bsinno/Bug/Show_User_Information
Fix: Return trimmed username
This commit is contained in:
@@ -88,12 +88,10 @@ public final class UserDetailsFormatter {
|
|||||||
* name to max 12 characters. @see
|
* name to max 12 characters. @see
|
||||||
* {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
|
* {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
|
||||||
*
|
*
|
||||||
* @param baseEntity
|
|
||||||
* the entity
|
|
||||||
* @return the formatted user name (max 12 characters) cannot be <null>
|
* @return the formatted user name (max 12 characters) cannot be <null>
|
||||||
*/
|
*/
|
||||||
public static String loadAndFormatCurrentUsername() {
|
public static String formatCurrentUsername() {
|
||||||
return loadAndFormatUsername(getCurrentUser().getUsername(), 12);
|
return loadAndFormatUsername(getCurrentUser().getUsername(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,6 +112,10 @@ public final class UserDetailsFormatter {
|
|||||||
*/
|
*/
|
||||||
public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
|
public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
|
||||||
final UserDetails userDetails = loadUserByUsername(username);
|
final UserDetails userDetails = loadUserByUsername(username);
|
||||||
|
return formatUserName(expectedNameLength, userDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatUserName(final int expectedNameLength, final UserDetails userDetails) {
|
||||||
if (!(userDetails instanceof UserPrincipal)) {
|
if (!(userDetails instanceof UserPrincipal)) {
|
||||||
return userDetails.getUsername();
|
return userDetails.getUsername();
|
||||||
}
|
}
|
||||||
@@ -134,7 +136,7 @@ public final class UserDetailsFormatter {
|
|||||||
if (StringUtils.isEmpty(trimmedUsername)) {
|
if (StringUtils.isEmpty(trimmedUsername)) {
|
||||||
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
|
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
|
||||||
}
|
}
|
||||||
return firstAndLastname;
|
return trimmedUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public final class DashboardMenu extends CustomComponent {
|
|||||||
final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null);
|
final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null);
|
||||||
|
|
||||||
final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
|
final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
|
||||||
final String formattedUsername = UserDetailsFormatter.loadAndFormatCurrentUsername();
|
final String formattedUsername = UserDetailsFormatter.formatCurrentUsername();
|
||||||
String tenantAndUsernameHtml = "";
|
String tenantAndUsernameHtml = "";
|
||||||
if (!StringUtils.isEmpty(formattedTenant)) {
|
if (!StringUtils.isEmpty(formattedTenant)) {
|
||||||
tenantAndUsernameHtml += formattedTenant + "<br>";
|
tenantAndUsernameHtml += formattedTenant + "<br>";
|
||||||
|
|||||||
Reference in New Issue
Block a user