[fc7ec52] | 1 | //package com.example.demo.controller;
|
---|
| 2 | //
|
---|
| 3 | //import com.example.demo.exceptions.InvalidUserCredentialsException;
|
---|
| 4 | //import com.example.demo.model.User;
|
---|
| 5 | //import com.example.demo.service.AuthService;
|
---|
| 6 | //import org.springframework.stereotype.Controller;
|
---|
| 7 | //import org.springframework.ui.Model;
|
---|
| 8 | //import org.springframework.web.bind.annotation.GetMapping;
|
---|
| 9 | //import org.springframework.web.bind.annotation.PostMapping;
|
---|
| 10 | //import org.springframework.web.bind.annotation.RequestMapping;
|
---|
| 11 | //
|
---|
| 12 | //import javax.servlet.http.HttpServletRequest;
|
---|
| 13 | //
|
---|
| 14 | //@Controller
|
---|
| 15 | //@RequestMapping("/login")
|
---|
| 16 | //public class LoginController {
|
---|
| 17 | //
|
---|
| 18 | // private final AuthService authService;
|
---|
| 19 | //
|
---|
| 20 | // public LoginController(AuthService authService) {
|
---|
| 21 | // this.authService = authService;
|
---|
| 22 | // }
|
---|
| 23 | //
|
---|
| 24 | // @GetMapping
|
---|
| 25 | // public String getLoginPage(Model model) {
|
---|
| 26 | // model.addAttribute("bodyContent","login");
|
---|
| 27 | // return "master-template";
|
---|
| 28 | // }
|
---|
| 29 | //
|
---|
| 30 | // @PostMapping
|
---|
| 31 | // public String login(HttpServletRequest request, Model model) {
|
---|
| 32 | // User user = null;
|
---|
| 33 | // try{
|
---|
| 34 | // user = this.authService.login(request.getParameter("user_username"),
|
---|
| 35 | // request.getParameter("user_password"));
|
---|
| 36 | // request.getSession().setAttribute("user", user);
|
---|
| 37 | // return "redirect:/movies";
|
---|
| 38 | // }
|
---|
| 39 | // catch (InvalidUserCredentialsException exception) {
|
---|
| 40 | // model.addAttribute("hasError", true);
|
---|
| 41 | // model.addAttribute("error", exception.getMessage());
|
---|
| 42 | // return "login";
|
---|
| 43 | // }
|
---|
| 44 | // }
|
---|
| 45 | //} |
---|