Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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 @@ -26,7 +26,19 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
if (userId != null && !userId.isEmpty()) {
List<SimpleGrantedAuthority> authorities = rolesHeader == null ? Collections.emptyList() :
Arrays.stream(rolesHeader.split(","))
.map(role -> new SimpleGrantedAuthority("ROLE_" + role.trim().toUpperCase()))
.map(role -> {
String roleUpper = role.trim().toUpperCase();
// Treat SUPER_ADMIN as ADMIN for authorization purposes
if ("SUPER_ADMIN".equals(roleUpper)) {
// Add both SUPER_ADMIN and ADMIN roles
return Arrays.asList(
new SimpleGrantedAuthority("ROLE_SUPER_ADMIN"),
new SimpleGrantedAuthority("ROLE_ADMIN")
);
}
return Collections.singletonList(new SimpleGrantedAuthority("ROLE_" + roleUpper));
})
.flatMap(List::stream)
.collect(Collectors.toList());

UsernamePasswordAuthenticationToken authentication =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,24 @@
@Builder
public class UserResponse {
private String userId;
private Long id; // Auth service returns Long id
private String username;
private String fullName;
private String email;
private String phone;
private String address;
private String role;
private String role; // Single role for backward compatibility
private List<String> roles; // Multiple roles from auth service
private Boolean active;
private Boolean enabled; // Auth service field
private Boolean accountLocked;
private Boolean emailVerified;
private String department;
private String profilePhoto;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
private LocalDateTime lastLogin;
private LocalDateTime lastLoginAt; // Auth service field

// Activity statistics (for detailed view)
private UserActivity activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ public List<UserResponse> getAllUsers(String role, Boolean active, int page, int
.collectList()
.block();

// Convert id to userId and ensure userId is set
if (users != null) {
users.forEach(user -> {
if (user.getUserId() == null && user.getId() != null) {
user.setUserId(String.valueOf(user.getId()));
}
});
}

return users != null ? users : Collections.emptyList();
} catch (Exception e) {
log.error("Error fetching users from auth service", e);
Expand All @@ -77,6 +86,12 @@ public UserResponse getUserById(String userId) {
if (user == null) {
throw new RuntimeException("User not found: " + userId);
}

// Convert id to userId if needed
if (user.getUserId() == null && user.getId() != null) {
user.setUserId(String.valueOf(user.getId()));
}

return user;
} catch (Exception e) {
log.error("Error fetching user: {}", userId, e);
Expand Down