jhipster find all records for admin and findByUserIsCurrentUser for current user

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();
     
    }

Comments

Popular posts from this blog

Angular cli ng command is not working

warning: LF will be replaced by CRLF in