@RequestMapping(value = {"/posts"}, method = RequestMethod.GET)
    public String posts(Model model, @RequestParam(required = false) String isPostCreated,
                        @RequestParam(required = false) String isPostUpdated,
                        @RequestParam(required = false) String isError) {

        UserDetails userDetails =
                (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        User currentUser = this.userService.getUserByName(userDetails.getUsername());

        List<Post> posts;
        if (currentUser.getRole().getId() == 1) {       //ROLE_ADMIN
            posts = this.postService.getAllPosts();
        }
        else {                                          //ROLE_MODERATOR
            posts = this.userService.getAllUserPosts(currentUser);
        }


        model.addAttribute("posts", posts);
        model.addAttribute("title", "Admin | Helix");


        if (posts.size() == 0) {
            model.addAttribute("isEmpty", true);
        }
        else {
            model.addAttribute("isEmpty", false);
        }

        if (isPostCreated != null && isPostCreated.equals("yes")) {
            model.addAttribute("isPostCreated", true);
        }
        else {
            model.addAttribute("isPostCreated", false);
        }

        if (isPostUpdated != null && isPostUpdated.equals("yes")) {
            model.addAttribute("isPostUpdated", true);
        }
        else {
            model.addAttribute("isPostUpdated", false);
        }

        if (isError != null && isError.equals("yes")) {
            model.addAttribute("isError", true);
        }
        else {
            model.addAttribute("isError", false);
        }

        return "admin/posts";
    }