Upgrade load user json dto if it is OAuth2Authentication
parent
b637fb08ec
commit
d01c8d0113
|
@ -38,11 +38,13 @@ public class UserServiceImpl implements UserService {
|
||||||
@Override
|
@Override
|
||||||
public UserJsonDto loadCurrentUserJsonDto() {
|
public UserJsonDto loadCurrentUserJsonDto() {
|
||||||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
final Object principal = authentication.getPrincipal();
|
||||||
|
|
||||||
if (authentication instanceof OAuth2Authentication && authentication.getPrincipal() instanceof String) {
|
if (authentication instanceof OAuth2Authentication &&
|
||||||
|
(principal instanceof String || principal instanceof org.springframework.security.core.userdetails.User)) {
|
||||||
return loadOauthUserJsonDto((OAuth2Authentication) authentication);
|
return loadOauthUserJsonDto((OAuth2Authentication) authentication);
|
||||||
} else {
|
} else {
|
||||||
final WdcyUserDetails userDetails = (WdcyUserDetails) authentication.getPrincipal();
|
final WdcyUserDetails userDetails = (WdcyUserDetails) principal;
|
||||||
return new UserJsonDto(userRepository.findByGuid(userDetails.user().guid()));
|
return new UserJsonDto(userRepository.findByGuid(userDetails.user().guid()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue