Skip to content

Commit

Permalink
DEAR-98 add authorization check
Browse files Browse the repository at this point in the history
  • Loading branch information
smuefsmuef committed Jul 29, 2024
1 parent 8e7923c commit f754cb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public class DashboardController {
@Autowired
private DashboardService dashboardService;

// todo ensure only logged in user can post his entries

@GetMapping("/{userId}")
public ResponseEntity<DashboardDTO> getDashboardDataByUserId(@PathVariable Integer userId) {
DashboardDTO dashboardDTO = dashboardService.getDashboardDataByUserId(userId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.fhnw.deardevbackend.services;

import ch.fhnw.deardevbackend.annotations.ValidateUserIdParam;
import ch.fhnw.deardevbackend.dto.*;
import ch.fhnw.deardevbackend.mapper.HappinessInsightMapper;
import ch.fhnw.deardevbackend.mapper.WorkKindInsightMapper;
Expand Down Expand Up @@ -37,7 +38,7 @@ public InsightsService(InsightsRepository insightsRepository,
}

@Transactional(readOnly = true)
public List<TeamHappinessInsightDTO> getDailyAveragesByUserId(Integer userId) {
public List<TeamHappinessInsightDTO> getDailyAveragesByUserId(@ValidateUserIdParam Integer userId) {
List<Integer> teamIds = teamMemberRepository.findTeamIdByUserId(userId);

return teamIds.stream().map(teamId -> {
Expand All @@ -62,7 +63,7 @@ public List<TeamHappinessInsightDTO> getDailyAveragesByUserId(Integer userId) {
}

@Transactional(readOnly = true)
public List<HappinessInsightDTO> getHappinessInsightsByTeam(Integer userId, Integer teamId, String sprint) {
public List<HappinessInsightDTO> getHappinessInsightsByTeam(@ValidateUserIdParam Integer userId, Integer teamId, String sprint) {
LocalDateTime startDate = null;
LocalDateTime endDate = LocalDateTime.now();

Expand Down Expand Up @@ -114,7 +115,7 @@ public List<HappinessInsightDTO> getHappinessInsightsByTeam(Integer userId, Inte


@Transactional(readOnly = true)
public List<TeamWorkKindInsightDTO> getWorkKindHappinessByUserId(Integer userId) {
public List<TeamWorkKindInsightDTO> getWorkKindHappinessByUserId(@ValidateUserIdParam Integer userId) {
List<Object[]> results = insightsRepository.findWorkKindHappinessByUserId(userId);

Map<Integer, List<WorkKindInsightDTO>> groupedByTeam = results.stream()
Expand Down

0 comments on commit f754cb7

Please sign in to comment.