Skip to content

Commit c690b3c

Browse files
Coderabbit comments updated
1 parent 9be3aa1 commit c690b3c

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/com/iemr/ecd/utils/mapper/RoleAuthenticationFilter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
5858
}
5959
Object userIdObj = extractAllClaims.get("userId");
6060
String userId = userIdObj != null ? userIdObj.toString() : null;
61-
62-
authRoles = redisService.getUserRoleFromCache(Long.valueOf(userId));
61+
if (null == userId || userId.trim().isEmpty()) {
62+
filterChain.doFilter(request, response);
63+
return;
64+
}
65+
Long userIdLong;
66+
try {
67+
userIdLong=Long.valueOf(userId);
68+
}catch (NumberFormatException ex) {
69+
logger.warn("Invalid userId format: {}",userId);
70+
filterChain.doFilter(request, response);
71+
return;
72+
}
73+
authRoles = redisService.getUserRoleFromCache(userIdLong);
6374
if (authRoles == null || authRoles.isEmpty()) {
6475
List<String> roles = userService.getUserRoles(Long.valueOf(userId)); // assuming this returns multiple roles
6576
authRoles = roles.stream()

0 commit comments

Comments
 (0)