patch credit

This commit is contained in:
jleroy
2024-04-29 16:02:06 +02:00
parent c068412213
commit d5e4012c79
23 changed files with 147 additions and 15 deletions

View File

@@ -44,7 +44,6 @@ dependencies {
//test
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//data
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}

View File

@@ -4,24 +4,13 @@ import com.google.i18n.phonenumbers.PhoneNumberUtil;
import org.apache.commons.validator.routines.EmailValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.filter.RequestContextFilter;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;
@Configuration
public class WebConfig {

View File

@@ -0,0 +1,44 @@
package fr.eni.enchere.controllers;
import fr.eni.enchere.bll.ArticleService;
import fr.eni.enchere.bll.UserService;
import fr.eni.enchere.bo.UserProfil;
import org.springframework.beans.factory.annotation.Autowired;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller()
@RequestMapping("/bank")
public class BankController {
@Autowired
private final UserService userService;
public BankController(UserService userService) {
this.userService = userService;
}
@GetMapping("/home")
public String homeCredit(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!authentication.getName().equals("anonymousUser")){
return "redirect:/accueil";
}
String username = authentication.getName();
UserProfil userProfile = userService.utilisateurByName(username);
model.addAttribute("userProfile", userProfile);
return "bank";
}
@PostMapping("/checkout")
public String addCreditCheckout() {
return "bank";
}
}

View File

@@ -83,11 +83,13 @@ public class ForgotPasswordRepositoryImpl implements ForgotPasswordRepository {
parameters.addValue("dateExpire", dateAgo.getTime());
namedParameterJdbcTemplate.update(sql, parameters);
//Envoyer un email
String link = "http://eni.enchere.horya.fr/forgotPassword?link=" + linkCreate.toString();
String link = "https://eni.enchere.horya.fr/forgotPassword?link=" + linkCreate.toString();
String linkLocal = "http://localhost:8800/forgotPassword?link=" + linkCreate.toString();
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("support@horya.fr");
message.setTo(email);
message.setSubject("ENI Enchere - Demmande de changement de mot de passe");
message.setText("Bonjour,\n\nVous avez demandé une réinitialisation de votre mot de passe. Veuillez utiliser le lien suivant pour procéder à la réinitialisation : " + link);
message.setText("Bonjour,\n\nVous avez demandé une réinitialisation de votre mot de passe. Veuillez utiliser le lien suivant pour procéder à la réinitialisation : " + link + "\n\n" + linkLocal);
javaMailSender.send(message);
}
}

View File

@@ -8,5 +8,7 @@ spring.mail.host=smtp.mail.ovh.net
spring.mail.port=465
spring.mail.username=support@horya.fr
spring.mail.password=5AQyQR%zg3qDfnh
spring.mail.properties.mail.transport.protocol=smtp
spring.mail.properties.mail.smtp.port=465
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.enable=true

View File

@@ -22,6 +22,7 @@ home.nav.vend = Sell an item
home.nav.login = Register / Log in
home.profil.profil = Profile
home.profil.logout = Log out
home.profil.bank = Credit
home.article.sellprice = Sale price:
home.article.seller = Seller:
home.article.end = End of auction:

View File

@@ -22,6 +22,7 @@ home.nav.vend = Vendre un article
home.nav.login = S'inscrire / Se connecter
home.profil.profil = Profil
home.profil.logout = D\u00e9connexion
home.profil.bank = Cr\u00e9diter
home.article.sellprice = Prix de vente:
home.article.seller = Vendeur:
home.article.end = Fin de l'ench\u00E8re:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html th:replace="~{modele-page :: layout('Créditer son compte',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="container-main" class="container py-5">
<h1 class="mb-4" th:text="#{article.add.heading}">Nouvelle vente</h1>
<form th:action="@{/article/new}" method="post" th:object="${article}" enctype="multipart/form-data" class="needs-validation" novalidate>
<div class="mb-3">
<label for="nom" class="form-label" th:text="#{article.add.form.label.name}">Article:</label>
<input type="text" class="form-control" th:field="*{nom}" id="nom" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="description" class="form-label" th:text="#{article.add.form.label.description}">Description:</label>
<textarea class="form-control" th:field="*{desc}" id="description" required></textarea>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="categorie" class="form-label" th:text="#{article.add.form.label.category}">Catégorie:</label>
<select class="form-control" th:field="*{numCategorie}" id="categorie" required>
<option th:each="categorie : ${categories}" th:value="${categorie.id}" th:text="${categorie.libelle}"></option>
</select>
<div class="invalid-feedback" th:text="#{article.add.form.validation.category}">Veuillez sélectionner une catégorie.</div>
</div>
<div class="mb-3">
<label for="photo" class="form-label" th:text="#{article.add.form.label.photo}">Photo de l'article:</label>
<input type="file" class="form-control" th:field="*{photo}" id="photo" accept="image/jpeg">
</div>
<div class="mb-3">
<label for="prix" class="form-label" th:text="#{article.add.form.label.starting_price}">Mise à prix:</label>
<input type="number" class="form-control" th:field="*{prixInitial}" id="prix" min="0" max="2000000000" step="0.01" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="dateDebut" class="form-label" th:text="#{article.add.form.label.start_date}">Date début enchère:</label>
<input type="date" class="form-control" id="dateDebut" name="dateDebut" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="dateFin" class="form-label" th:text="#{article.add.form.label.end_date}">Date fin enchère:</label>
<input type="date" class="form-control" id="dateFin" name="dateFin" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<h4 th:text="#{article.add.form.label.removal}">Retrait</h4>
<div class="mb-3">
<label for="rue" class="form-label" th:text="#{article.add.form.label.street}">Rue:</label>
<input type="text" class="form-control" id="rue" name="rue" th:field="${user.rue}" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="codePostal" class="form-label" th:text="#{article.add.form.label.postal_code}">Code postal:</label>
<input type="text" class="form-control" id="codePostal" name="code_postal" th:field="${user.code_postal}" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<div class="mb-3">
<label for="ville" class="form-label" th:text="#{article.add.form.label.city}">Ville:</label>
<input type="text" class="form-control" id="ville" name="ville" th:field="${user.ville}" required>
<div class="invalid-feedback" th:text="#{article.add.form.validation.required}">Ce champ est requis.</div>
</div>
<button type="submit" class="btn btn-primary" th:text="#{article.add.form.button.save}">Enregistrer</button>
<div th:if="${param.erreur != null}" class="mt-3">
<p style="color: red;" th:text="${param.erreur}"></p>
</div>
</form>
<form th:action="@{/accueil}" method="post" class="mt-3">
<button type="submit" class="btn btn-secondary" th:text="#{article.add.form.button.cancel}">Annuler</button>
</form>
<script>
var today = new Date();
var tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
var formattedDateToday = today.toISOString().split('T')[0];
var formattedDateTomorrow = tomorrow.toISOString().split('T')[0];
document.getElementById('dateDebut').min = formattedDateToday;
document.getElementById('dateFin').min = formattedDateTomorrow;
</script>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
</body>
</html>

View File

@@ -45,6 +45,7 @@
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="/profil" th:text="#{home.profil.profil}"></a> <!-- Bouton de profil -->
<a class="dropdown-item" href="/bank" th:text="#{home.profil.bank}"></a>
<a class="dropdown-item" th:if="${#authorization.expression('hasRole(''ADMIN'')')}" href="/admin"> Administration </a>
<a class="dropdown-item" href="/logout" th:text="#{home.profil.logout}"></a> <!-- Bouton de déconnexion -->
<div class="dropdown-divider"></div> <!-- Diviseur -->