This commit is contained in:
ovo 2024-12-07 19:51:53 +08:00
parent 11bec69f6b
commit 287ac0be85
1 changed files with 6 additions and 4 deletions

View File

@ -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<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
return new CustomUserDetails(
user.getId(),
user.getUsername(),
user.getPassword(),
null,
authorities,
user.getStatus() == 1
);