Merge branch 'Johan'
This commit is contained in:
@@ -2,14 +2,8 @@ package fr.eni.enchere.controllers;
|
|||||||
|
|
||||||
import fr.eni.enchere.bll.CategorieService;
|
import fr.eni.enchere.bll.CategorieService;
|
||||||
import fr.eni.enchere.bll.UserService;
|
import fr.eni.enchere.bll.UserService;
|
||||||
import fr.eni.enchere.bo.Article;
|
|
||||||
import fr.eni.enchere.bo.Categorie;
|
import fr.eni.enchere.bo.Categorie;
|
||||||
import fr.eni.enchere.bo.Retrait;
|
|
||||||
import fr.eni.enchere.bo.UserProfil;
|
|
||||||
import fr.eni.enchere.dal.UserRepositoryImpl;
|
import fr.eni.enchere.dal.UserRepositoryImpl;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -75,6 +69,8 @@ public class AdminController {
|
|||||||
userService.enableUtilisateur(id);
|
userService.enableUtilisateur(id);
|
||||||
}else {
|
}else {
|
||||||
userService.disableUtilisateur(id);
|
userService.disableUtilisateur(id);
|
||||||
|
//Désactiver tout
|
||||||
|
|
||||||
}
|
}
|
||||||
return "redirect:/admin";
|
return "redirect:/admin";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class InscriptionController {
|
|||||||
// Sinon, enregistrer l'utilisateur et rediriger vers la page de connexion
|
// Sinon, enregistrer l'utilisateur et rediriger vers la page de connexion
|
||||||
userService.setUtilisateur(userProfile);
|
userService.setUtilisateur(userProfile);
|
||||||
// Dans votre méthode setUser après la validation réussie
|
// Dans votre méthode setUser après la validation réussie
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/login");
|
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/login/register");
|
||||||
builder.queryParam("username", userProfile.getPseudo());
|
builder.queryParam("username", userProfile.getPseudo());
|
||||||
builder.queryParam("password", userProfile.getPassword());
|
builder.queryParam("password", userProfile.getPassword());
|
||||||
// Rediriger vers la méthode POST de /login avec les paramètres
|
// Rediriger vers la méthode POST de /login avec les paramètres
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/login")
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -22,7 +24,7 @@ public class LoginController {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/login")
|
@GetMapping
|
||||||
public String login(Model modele) {
|
public String login(Model modele) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (!authentication.getName().equals("anonymousUser")){
|
if (!authentication.getName().equals("anonymousUser")){
|
||||||
@@ -31,13 +33,29 @@ public class LoginController {
|
|||||||
return "security/login";
|
return "security/login";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping
|
||||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password) {
|
public String login(@RequestParam("username") String username, @RequestParam("password") String password,
|
||||||
|
@RequestParam(value = "username", required = false) String usernameByRegister,
|
||||||
|
@RequestParam(value = "password", required = false) String passwordByRegister) {
|
||||||
UserProfil user = userService.utilisateurByName(username);
|
UserProfil user = userService.utilisateurByName(username);
|
||||||
|
UserProfil userRegister = userService.utilisateurByName(usernameByRegister);
|
||||||
if (user != null && user.getPassword().equals(password)) {
|
if (user != null && user.getPassword().equals(password)) {
|
||||||
return "redirect:/enchere";
|
return "redirect:/enchere";
|
||||||
} else {
|
} else {
|
||||||
return "redirect:/security/login?error";
|
return "redirect:/security/login?error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/register")
|
||||||
|
public String login(@RequestParam(value = "username", required = true) String usernameByRegister,
|
||||||
|
@RequestParam(value = "password", required = true) String passwordByRegister) {
|
||||||
|
UserProfil userRegister = userService.utilisateurByName(usernameByRegister);
|
||||||
|
System.out.println(usernameByRegister);
|
||||||
|
if (userRegister != null && userRegister.getPassword().equals(passwordByRegister)) {
|
||||||
|
return "redirect:/enchere";
|
||||||
|
} else {
|
||||||
|
return "redirect:/security/login?error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class EnchereRepositoryImpl implements EnchereRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Enchere> findByIdArticle(int idArticle) {
|
public List<Enchere> findByIdArticle(int idArticle) {
|
||||||
String sql = "SELECT * FROM ENCHERES WHERE no_article = ?";
|
String sql = "SELECT * FROM ENCHERES WHERE no_article = ? AND isDelete = 0";
|
||||||
List<Enchere> encheres = jdbcTemplate.query(sql, new EnchereRowMapper(), idArticle);
|
List<Enchere> encheres = jdbcTemplate.query(sql, new EnchereRowMapper(), idArticle);
|
||||||
return encheres;
|
return encheres;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,28 +56,28 @@ public class UserRepositoryImpl implements UserRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfil findByUsername(String username) {
|
public UserProfil findByUsername(String username) {
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = ? OR email = ? AND isDelete = 0";
|
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = ? OR email = ? AND isDelete = 0 AND isDisabled = 0";
|
||||||
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), username, username);
|
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), username, username);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfil findUserByEmail(String email) {
|
public UserProfil findUserByEmail(String email) {
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE email = ? AND isDelete = 0";
|
String sql = "SELECT * FROM UTILISATEURS WHERE email = ? AND isDelete = 0 AND isDisabled = 0";
|
||||||
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), email);
|
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), email);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> findAllUsernames() {
|
public List<String> findAllUsernames() {
|
||||||
String sql = "SELECT pseudo FROM UTILISATEURS WHERE isDelete = 0";
|
String sql = "SELECT pseudo FROM UTILISATEURS WHERE isDelete = 0 AND isDisabled = 0";
|
||||||
List<String> usernames = jdbcTemplate.queryForList(sql, String.class);
|
List<String> usernames = jdbcTemplate.queryForList(sql, String.class);
|
||||||
return usernames;
|
return usernames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> findAllEmail() {
|
public List<String> findAllEmail() {
|
||||||
String sql = "SELECT email FROM UTILISATEURS WHERE isDelete = 0";
|
String sql = "SELECT email FROM UTILISATEURS WHERE isDelete = 0 AND isDisabled = 0";
|
||||||
List<String> email = jdbcTemplate.queryForList(sql, String.class);
|
List<String> email = jdbcTemplate.queryForList(sql, String.class);
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class UserRepositoryImpl implements UserRepository {
|
|||||||
@Override
|
@Override
|
||||||
public String findByEmail(String email) {
|
public String findByEmail(String email) {
|
||||||
//Vérifie si un email existe dans la base et est valide
|
//Vérifie si un email existe dans la base et est valide
|
||||||
String sql = "SELECT email FROM UTILISATEURS WHERE isDisabled = 0 AND email = ?";
|
String sql = "SELECT email FROM UTILISATEURS WHERE isDisabled = 0 AND email = ? AND isDelete = 0";
|
||||||
try {
|
try {
|
||||||
return jdbcTemplate.queryForObject(sql, new Object[]{email}, String.class);
|
return jdbcTemplate.queryForObject(sql, new Object[]{email}, String.class);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
@@ -96,14 +96,14 @@ public class UserRepositoryImpl implements UserRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserProfil> findAll() {
|
public List<UserProfil> findAll() {
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE isDelete = 0";
|
String sql = "SELECT * FROM UTILISATEURS WHERE isDelete = 0 AND isDisabled = 0";
|
||||||
List<UserProfil> users = jdbcTemplate.query(sql, new UserRowMapper());
|
List<UserProfil> users = jdbcTemplate.query(sql, new UserRowMapper());
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfil findById(int id) {
|
public UserProfil findById(int id) {
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE no_utilisateur = ?";
|
String sql = "SELECT * FROM UTILISATEURS WHERE no_utilisateur = ? AND isDelete = 0 AND isDisabled = 0";
|
||||||
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), id);
|
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), id);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/static/images/paiementSecu.png
Normal file
BIN
src/main/resources/static/images/paiementSecu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -6,55 +6,60 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container" id="container-main">
|
<div class="container" id="container-main">
|
||||||
<div class="row justify-content-center mt-5">
|
<div class="row mt-5">
|
||||||
<form th:action="@{/bank/checkout}" method="post" th:object="${bank}" class="needs-validation" novalidate>
|
<div class="col-md-8">
|
||||||
<div class="mb-3">
|
<form th:action="@{/bank/checkout}" method="post" th:object="${bank}" class="needs-validation" novalidate>
|
||||||
<label for="cartAmount" class="form-label">Nombre de crédits:</label>
|
<div class="mb-3">
|
||||||
<input type="number" class="form-control" th:field="*{cartAmount}" id="cartAmount" step="0.01" max="2000000" required/>
|
<label for="cartAmount" class="form-label">Nombre de crédits:</label>
|
||||||
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartAmount')}">
|
<input type="number" class="form-control" th:field="*{cartAmount}" id="cartAmount" step="0.01" max="2000000" required/>
|
||||||
<ul>
|
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartAmount')}">
|
||||||
<li th:each="erreur: ${#fields.errors('cartAmount')}" th:text="${erreur}"></li>
|
<ul>
|
||||||
</ul>
|
<li th:each="erreur: ${#fields.errors('cartAmount')}" th:text="${erreur}"></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mb-3">
|
||||||
<div class="mb-3">
|
<label for="cartNumber" class="form-label">Numéro de carte:</label>
|
||||||
<label for="cartNumber" class="form-label">Numéro de carte:</label>
|
<input type="text" class="form-control" th:field="*{cartNumber}" id="cartNumber" pattern="[0-9]{16}" maxlength="16" placeholder="1234 5678 9012 3456" required/>
|
||||||
<input type="text" class="form-control" th:field="*{cartNumber}" id="cartNumber" pattern="[0-9]{16}" maxlength="16" placeholder="1234 5678 9012 3456" required/>
|
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartNumber')}">
|
||||||
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartNumber')}">
|
<ul>
|
||||||
<ul>
|
<li th:each="erreur: ${#fields.errors('cartNumber')}" th:text="${erreur}"></li>
|
||||||
<li th:each="erreur: ${#fields.errors('cartNumber')}" th:text="${erreur}"></li>
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mb-3">
|
||||||
<div class="mb-3">
|
<label for="cartExpired" class="form-label">Date d'expiration:</label>
|
||||||
<label for="cartExpired" class="form-label">Date d'expiration:</label>
|
<input type="text" class="form-control" th:field="*{cartExpired}" id="cartExpired" pattern="(0[1-9]|1[0-2])\/[0-9]{4}" placeholder="MM/YYYY" required/>
|
||||||
<input type="text" class="form-control" th:field="*{cartExpired}" id="cartExpired" pattern="(0[1-9]|1[0-2])\/[0-9]{4}" placeholder="MM/YYYY" required/>
|
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartExpired')}">
|
||||||
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartExpired')}">
|
<ul>
|
||||||
<ul>
|
<li th:each="erreur: ${#fields.errors('cartExpired')}" th:text="${erreur}"></li>
|
||||||
<li th:each="erreur: ${#fields.errors('cartExpired')}" th:text="${erreur}"></li>
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mb-3">
|
||||||
<div class="mb-3">
|
<label for="cartCVV" class="form-label">CVV:</label>
|
||||||
<label for="cartCVV" class="form-label">CVV:</label>
|
<input type="text" class="form-control" th:field="*{cartCVV}" id="cartCVV" pattern="[0-9]{3}" maxlength="3" required/>
|
||||||
<input type="text" class="form-control" th:field="*{cartCVV}" id="cartCVV" pattern="[0-9]{3}" maxlength="3" required/>
|
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartCVV')}">
|
||||||
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartCVV')}">
|
<ul>
|
||||||
<ul>
|
<li th:each="erreur: ${#fields.errors('cartCVV')}" th:text="${erreur}"></li>
|
||||||
<li th:each="erreur: ${#fields.errors('cartCVV')}" th:text="${erreur}"></li>
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mb-3">
|
||||||
<div class="mb-3">
|
<label for="cartName" class="form-label">Nom du titulaire de la carte:</label>
|
||||||
<label for="cartName" class="form-label">Nom du titulaire de la carte:</label>
|
<input type="text" class="form-control" th:field="*{cartName}" id="cartName" required/>
|
||||||
<input type="text" class="form-control" th:field="*{cartName}" id="cartName" required/>
|
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartName')}">
|
||||||
<div class="is-invalid text-danger" th:if="${#fields.hasErrors('cartName')}">
|
<ul>
|
||||||
<ul>
|
<li th:each="erreur: ${#fields.errors('cartName')}" th:text="${erreur}"></li>
|
||||||
<li th:each="erreur: ${#fields.errors('cartName')}" th:text="${erreur}"></li>
|
</ul>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button type="submit" class="btn btn-primary w-100">Payer</button>
|
||||||
<button type="submit" class="btn btn-primary w-100">Payer</button>
|
</form>
|
||||||
</form>
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<img src="/images/paiementSecu.png" class="img-fluid" alt="Paiement sécurisé" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user