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

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