diff --git a/src/main/java/com/guwan/backend/security/UserDetailsServiceImpl.java b/src/main/java/com/guwan/backend/security/UserDetailsServiceImpl.java index 41732f3..95bd3be 100644 --- a/src/main/java/com/guwan/backend/security/UserDetailsServiceImpl.java +++ b/src/main/java/com/guwan/backend/security/UserDetailsServiceImpl.java @@ -24,7 +24,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { if (user == null) { throw new UsernameNotFoundException("用户不存在"); } - return convertToUserDetails(user); + return convertToUserDetailsWithoutPassword(user); } public UserDetails loadUserById(Long userId) throws UsernameNotFoundException { @@ -32,17 +32,19 @@ public class UserDetailsServiceImpl implements UserDetailsService { if (user == null) { throw new UsernameNotFoundException("用户不存在"); } - return convertToUserDetails(user); + return convertToUserDetailsWithoutPassword(user); } - private UserDetails convertToUserDetails(UserDTO user) { + + + private UserDetails convertToUserDetailsWithoutPassword(UserDTO user) { List authorities = new ArrayList<>(); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); return new CustomUserDetails( user.getId(), user.getUsername(), - user.getPassword(), + null, authorities, user.getStatus() == 1 );