Problem :
Normal user should not fetch all the records in entity ,and admin user should be able to fetch the records.
Solution:
public List<FoodItem> getAllFoodItems() {
log.debug("REST request to get all FoodItems");
if(SecurityUtils.getCurrentUserLogin().get().equalsIgnoreCase("admin"))
{
return foodItemRepository.findAll();
}
return foodItemRepository.findByUserIsCurrentUser();
}
0 Comments