conflict done

This commit is contained in:
Parpaillax
2024-04-23 15:08:25 +02:00
parent 3ca27ce33d
commit 38fdf680d9
10 changed files with 99 additions and 32 deletions

View File

@@ -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";
}
}
}