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.UserService;
|
||||
import fr.eni.enchere.bo.Article;
|
||||
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 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.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -75,6 +69,8 @@ public class AdminController {
|
||||
userService.enableUtilisateur(id);
|
||||
}else {
|
||||
userService.disableUtilisateur(id);
|
||||
//Désactiver tout
|
||||
|
||||
}
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class InscriptionController {
|
||||
// Sinon, enregistrer l'utilisateur et rediriger vers la page de connexion
|
||||
userService.setUtilisateur(userProfile);
|
||||
// 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("password", userProfile.getPassword());
|
||||
// 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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/login")
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
@@ -22,7 +24,7 @@ public class LoginController {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
@GetMapping
|
||||
public String login(Model modele) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (!authentication.getName().equals("anonymousUser")){
|
||||
@@ -31,13 +33,29 @@ public class LoginController {
|
||||
return "security/login";
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password) {
|
||||
@PostMapping
|
||||
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 userRegister = userService.utilisateurByName(usernameByRegister);
|
||||
if (user != null && user.getPassword().equals(password)) {
|
||||
return "redirect:/enchere";
|
||||
} else {
|
||||
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
|
||||
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);
|
||||
return encheres;
|
||||
}
|
||||
|
||||
@@ -56,28 +56,28 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
@Override
|
||||
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);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
return usernames;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
return email;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
@Override
|
||||
public String findByEmail(String email) {
|
||||
//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 {
|
||||
return jdbcTemplate.queryForObject(sql, new Object[]{email}, String.class);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
@@ -96,14 +96,14 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
@Override
|
||||
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());
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
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,7 +6,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container-main">
|
||||
<div class="row justify-content-center mt-5">
|
||||
<div class="row mt-5">
|
||||
<div class="col-md-8">
|
||||
<form th:action="@{/bank/checkout}" method="post" th:object="${bank}" class="needs-validation" novalidate>
|
||||
<div class="mb-3">
|
||||
<label for="cartAmount" class="form-label">Nombre de crédits:</label>
|
||||
@@ -56,6 +57,10 @@
|
||||
<button type="submit" class="btn btn-primary w-100">Payer</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<img src="/images/paiementSecu.png" class="img-fluid" alt="Paiement sécurisé" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user