Skip to content

Commit

Permalink
GAP-2290: Fixing transfer ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicwest committed Nov 10, 2023
1 parent a26dc05 commit 8697769
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ public ResponseEntity<String> updateGrantOwnership(@PathVariable final Integer s
return ResponseEntity.ok("Grant ownership updated successfully");
}

@GetMapping("/admin/{adminId}")
@GetMapping("/admin/{sub}")
@PreAuthorize("hasRole('SUPER_ADMIN')")
public ResponseEntity<List<SchemeDTO>> getAdminsSchemes(final @PathVariable Integer adminId,
public ResponseEntity<List<SchemeDTO>> getAdminsSchemes(final @PathVariable String sub,
final HttpServletRequest request) {
final Integer adminId = userService.getGrantAdminIdFromSub(sub);
List<SchemeDTO> schemes = this.schemeService.getAdminsSchemes(adminId);
return ResponseEntity.ok().body(schemes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@

@Repository
public interface GrantAdminRepository extends JpaRepository<GrantAdmin, Integer> {

Optional<GrantAdmin> findByGapUserUserSub(String userId);

Optional<GrantAdmin> findByGapUserUserSub(String sub);
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ public int getGrantAdminIdFromUserServiceEmail(final String email, final String
}
}

public Integer getGrantAdminIdFromSub(final String sub) {
return grantAdminRepository.findByGapUserUserSub(sub)
.orElseThrow(() -> new NotFoundException("No grant admin found for sub: " + sub))
.getId();
}
}

0 comments on commit 8697769

Please sign in to comment.