diff --git a/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java b/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java index 092e39b..1557e1e 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java +++ b/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java @@ -77,7 +77,10 @@ public class UsersController { @ApiResponse(code = 404, message = "The user doesn't exist"), // @ApiResponse(code = 500, message = "Expired or invalid JWT token")}) public UsersResponseDTO search(@ApiParam("Username") @PathVariable String username) { - return modelMapper.map(userService.search(username), UsersResponseDTO.class); + UsersResponseDTO urDTO = modelMapper.map(userService.search(username), UsersResponseDTO.class); + urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId())); + urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId())); + return urDTO; } @GetMapping(value = "/me") @@ -88,7 +91,10 @@ public class UsersController { @ApiResponse(code = 403, message = "Access denied"), // @ApiResponse(code = 500, message = "Expired or invalid JWT token")}) public UsersResponseDTO whoami(HttpServletRequest req) { - return modelMapper.map(userService.whoami(req), UsersResponseDTO.class); + UsersResponseDTO urDTO = modelMapper.map(userService.whoami(req), UsersResponseDTO.class); + urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId())); + urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId())); + return urDTO; } @GetMapping("/refresh") diff --git a/src/main/java/org/waterproofingdata/wpdauth/dto/UsersRequestDTO.java b/src/main/java/org/waterproofingdata/wpdauth/dto/UsersRequestDTO.java index bae6cfe..696fd43 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/dto/UsersRequestDTO.java +++ b/src/main/java/org/waterproofingdata/wpdauth/dto/UsersRequestDTO.java @@ -9,6 +9,7 @@ import lombok.Setter; public class UsersRequestDTO { @ApiModelProperty(position = 0) private String username; + @ApiModelProperty(position = 1) private String password; } diff --git a/src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java b/src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java index 269de36..453b840 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java +++ b/src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java @@ -26,5 +26,5 @@ public class UsersResponseDTO { EduCemadenOrganizations eduCemadenOrganization; @ApiModelProperty(position = 4) - List rolesProviderActivationKey; + List rolesProviderActivationKeys; } diff --git a/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java b/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java index 9f706f8..bdcf654 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java +++ b/src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java @@ -11,9 +11,9 @@ public interface EduCemadenOrganizationsRepository extends JpaRepository { +public interface UsersRolesproviderActivationKeyRepository extends JpaRepository { List findByUsersid(Integer usersid); } diff --git a/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java b/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java index 81a6795..e78f850 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java +++ b/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java @@ -1,5 +1,6 @@ package org.waterproofingdata.wpdauth.service; +import java.util.List; import java.util.UUID; import javax.servlet.http.HttpServletRequest; @@ -12,9 +13,12 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.waterproofingdata.wpdauth.exception.CustomException; +import org.waterproofingdata.wpdauth.model.EduCemadenOrganizations; import org.waterproofingdata.wpdauth.model.Users; +import org.waterproofingdata.wpdauth.model.UsersRolesproviderActivationKey; import org.waterproofingdata.wpdauth.repository.EduCemadenOrganizationsRepository; import org.waterproofingdata.wpdauth.repository.UsersRepository; +import org.waterproofingdata.wpdauth.repository.UsersRolesproviderActivationKeyRepository; import org.waterproofingdata.wpdauth.security.JwtTokenProvider; @Service @@ -24,6 +28,9 @@ public class UsersService { @Autowired private EduCemadenOrganizationsRepository eduCemadenOrganizationsRepository; + + @Autowired + private UsersRolesproviderActivationKeyRepository usersRolesproviderActivationKeyRepository; @Autowired private PasswordEncoder passwordEncoder; @@ -76,6 +83,14 @@ public class UsersService { public Users whoami(HttpServletRequest req) { return userRepository.findByUsername(jwtTokenProvider.getUsername(jwtTokenProvider.resolveToken(req))); } + + public EduCemadenOrganizations findEduCemadenOrganizationById(Integer userid) { + return eduCemadenOrganizationsRepository.findByUserId(userid); + } + + public List findRolesproviderActivationKeysById(Integer usersid) { + return usersRolesproviderActivationKeyRepository.findByUsersid(usersid); + } public String refresh(String username) { return jwtTokenProvider.createToken(username, userRepository.findByUsername(username).getRoles());