From 287ac0be85b18859f33f9d80ac9acfa91d80c62e Mon Sep 17 00:00:00 2001 From: ovo Date: Sat, 7 Dec 2024 19:51:53 +0800 Subject: [PATCH] feat: --- .../guwan/backend/security/UserDetailsServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 );