}
if (request != null && modelAndView != null && (!(modelAndView.getView() instanceof RedirectView) && !modelAndView.getViewName().startsWith("redirect:"))) {
User user = userService.getUserFromSecurityContext();
if (user != null) {
ApplicationType deviceType = new UserAgentInfo(request.getHeader("User-Agent"), request.getHeader("Accept")).getApplicationType();
// Get categories for side menu
List<Category> categories = userService.getCategoriesForUser(user, deviceType, SortOrder.ASCENDING);
List<MenuItem> categoryMenuItems = new ArrayList<MenuItem>();
if (categories != null) {
for (Category category : categories) {