conflict done
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package fr.eni.enchere.controllers;
|
||||
|
||||
import fr.eni.enchere.bll.UserService;
|
||||
import fr.eni.enchere.bo.UserProfil;
|
||||
import fr.eni.enchere.dal.UserRepository;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
public LoginController(UserService userService) {
|
||||
super();
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login(Model modele) {
|
||||
return "security/login";
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session) {
|
||||
UserProfil user = userService.userByName(username);
|
||||
System.out.println("test");
|
||||
if (user != null && user.getPassword().equals(password)) {
|
||||
return "redirect:/accueil";
|
||||
} else {
|
||||
return "redirect:/security/login?error";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user