Ignore:
Timestamp:
02/10/23 00:10:41 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
73f0dbc
Parents:
5444409
Message:

added authorization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/web/HomeController.java

    r5444409 r01a1ca6  
    259259    }
    260260    @GetMapping("/myTickets")
    261     public  String getMyTicketsPage(Model model,HttpSession session)
    262     {
    263         model.addAttribute("tickets",ticketService.findAllByCustomer((Customer) session.getAttribute("user")));
     261    public  String getMyTicketsPage(Model model,HttpServletRequest request)
     262    {
     263        Customer customer=customerService.findByUsername(request.getRemoteUser());
     264        model.addAttribute("tickets",ticketService.findAllByCustomer(customer));
    264265        model.addAttribute("bodyContent","myTickets");
    265266        return "master-template";
     
    380381    @PostMapping("/makeReservation")
    381382    @Transactional
    382     public String createTicketForReservation(@RequestParam Long film,@RequestParam Long projection,@RequestParam Long id_seat,@RequestParam String discount)
     383    public String createTicketForReservation(@RequestParam Long film,@RequestParam Long projection,@RequestParam Long id_seat,@RequestParam String discount,HttpServletRequest request, HttpServletResponse respons)
    383384    {
    384385        Ticket t;
     386        Customer customer=customerService.findByUsername(request.getRemoteUser());
    385387        Projection projection1=projectionService.findById(projection.intValue());
    386388        if(projection1.getDiscount().equals(discount)){
    387             t=ticketService.saveWithDiscount(LocalDate.now(),customerService.getCustomerById(2).get(),projection1,projection1.getDiscount(),seatService.getSeatById(id_seat.intValue()).get());
     389            t=ticketService.saveWithDiscount(LocalDate.now(),customer,projection1,projection1.getDiscount(),seatService.getSeatById(id_seat.intValue()).get());
    388390        }else{
    389             t=ticketService.saveWithout(LocalDate.now(),customerService.getCustomerById(4).get(),projection1,seatService.getSeatById(id_seat.intValue()).get());
     391            t=ticketService.saveWithout(LocalDate.now(),customer,projection1,seatService.getSeatById(id_seat.intValue()).get());
    390392        }
    391393        Integer price=ticketService.priceForTicket(t.getId_ticket());
    392394        t.setPrice(price);
    393         return "redirect:/home";
     395        return "redirect:/myTickets";
    394396    }
    395397
Note: See TracChangeset for help on using the changeset viewer.