Ignore:
Timestamp:
02/07/23 13:48:25 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
fc448f5
Parents:
f7b0906
Message:

changes for login (not working)

File:
1 edited

Legend:

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

    rf7b0906 rd7f5da9  
    7777
    7878    @PostMapping("/login")
    79     public String login(@RequestParam String username,@RequestParam String password,Model model, HttpSession session)
    80     {
    81         User user = null;
    82         try {
    83             user=userService.login(username,password);
    84             session.setAttribute("sessionUser",user);
    85             model.addAttribute("user",user);
     79    public String login(@RequestParam String username,
     80                        @RequestParam String password,Model model, HttpSession session)
     81    {
     82//        User user = null;
     83//        try {
     84           User user=userService.login(username,password);
     85        System.out.println(user.getFirst_name());
     86//            session.setAttribute("sessionUser",user);
     87//            model.addAttribute("user",user);
    8688            return "redirect:/home";
    87 
    88         }catch (UserNotFoundException e)
    89         {
    90             model.addAttribute("hasError", true);
    91             model.addAttribute("error", e.getMessage());
    92             return "login";
    93         }
     89//
     90//        }catch (UserNotFoundException e)
     91//        {
     92//            model.addAttribute("hasError", true);
     93//            model.addAttribute("error", e.getMessage());
     94//            return "login";
     95//        }
    9496
    9597    }
     
    106108    {
    107109        try {
    108            User user=userService.register(first_name,last_name,username,email,number,password,repeatedPassword,role);
     110           userService.register(first_name,last_name,username,email,number,password,role);
    109111            return "redirect:/login";
    110112        }catch (PasswordsDoNotMatchException exception)
Note: See TracChangeset for help on using the changeset viewer.