gestion creation user #238

Merged
judaur2005 merged 1 commits from features/fiche_refonte into develop 2026-07-03 18:57:58 +00:00
16 changed files with 42 additions and 34 deletions
Showing only changes of commit 9e535bc0e7 - Show all commits

View File

@@ -95,11 +95,11 @@ public class UserController {
} }
} }
@PostMapping("/reset-password") @GetMapping("/request-reset-password")
@PreAuthorize("hasAuthority('UPDATE_USER')") //@PreAuthorize("hasAuthority('UPDATE_USER')")
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> resetUserPassword(@RequestParam String login) {
try { try {
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername()); UserPaylaodWeb userPaylaodWeb= userService.requestResetPassword(login);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."), new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."),
HttpStatus.OK HttpStatus.OK

View File

@@ -95,7 +95,7 @@ public class DemandeReinitialisationMPServiceImpl implements DemandeReinitialisa
if (demandeReinitialisationMPOptional.isPresent()) { if (demandeReinitialisationMPOptional.isPresent()) {
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPOptional.get(); DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPOptional.get();
User user = demandeReinitialisationMP.getUser(); User user = demandeReinitialisationMP.getUser();
userService.resetPassword(user.getUsername()); // userService.resetPassword(user.getUsername());
demandeReinitialisationMP.setEtatDemande(EtatDemande.TRAITE); demandeReinitialisationMP.setEtatDemande(EtatDemande.TRAITE);
return demandeReinitialisationMPRepository.save(demandeReinitialisationMP); return demandeReinitialisationMPRepository.save(demandeReinitialisationMP);
} else { } else {

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.implementations.user;
import io.gmss.fiscad.entities.infocad.parametre.Structure; import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.exceptions.ApplicationException;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService; import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
@@ -245,15 +246,23 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public UserPaylaodWeb resetPassword(String username) { public UserPaylaodWeb requestResetPassword(String username) {
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException( User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
String.format("L'utilisateur %s n'existe pas.", username) String.format("L'utilisateur %s n'existe pas.", username)
)); ));
String password = stringService.generatePassword();
user.setPassword(passwordEncoder.encode(password));
user.setResetPassword(true); user.setResetPassword(true);
user.setTokenDate(LocalDateTime.now());
String token= stringService.getUniqueString();
user.setToken(token);
user= userRepository.save(user); user= userRepository.save(user);
mailService.sendAccountReinitMail(user,password);
mailService.sendValidationMail(user.getEmail(),
user.getPrenom() + " " + user.getNom(),
user.getUsername(),
reseturl + token);
Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId()); Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId());
return optionalUserPaylaodWeb.orElse(null); return optionalUserPaylaodWeb.orElse(null);
} }
@@ -266,7 +275,6 @@ public class UserServiceImpl implements UserService {
user.setPassword(passwordEncoder.encode(password)); user.setPassword(passwordEncoder.encode(password));
user.setResetPassword(false); user.setResetPassword(false);
user= userRepository.save(user); user= userRepository.save(user);
// mailService.sendAccountReinitMail(user,password);
Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId()); Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId());
return optionalUserPaylaodWeb.orElse(null); return optionalUserPaylaodWeb.orElse(null);
} }
@@ -347,13 +355,12 @@ public class UserServiceImpl implements UserService {
public Boolean validationTokenResetPassword(String token) { public Boolean validationTokenResetPassword(String token) {
Optional<User> optionalUser=userRepository.findByToken(token); Optional<User> optionalUser=userRepository.findByToken(token);
if(optionalUser.isEmpty()){ if(optionalUser.isEmpty()){
return false; throw new ApplicationException("Token invalide") ;
} }
LocalDateTime tokenDate= optionalUser.get().getTokenDate(); LocalDateTime tokenDate= optionalUser.get().getTokenDate();
if(isTokenExpired(tokenDate)){ if(isTokenExpired(tokenDate)){
return false ; throw new ApplicationException("Token expiré") ;
} }
return true; return true;
} }
@@ -380,7 +387,7 @@ public class UserServiceImpl implements UserService {
LocalDateTime dateExpiration = calculerDateExpiration(dateToken); LocalDateTime dateExpiration = calculerDateExpiration(dateToken);
return !LocalDateTime.now().isBefore(dateExpiration); return LocalDateTime.now().isBefore(dateExpiration);
} }
} }

View File

@@ -45,7 +45,7 @@ public interface UserService {
User activateUser(Long id); User activateUser(Long id);
User disactivateUser(Long id); User disactivateUser(Long id);
UserPaylaodWeb resetPassword(String username); UserPaylaodWeb requestResetPassword(String username);
UserPaylaodWeb resetPasswordByMail(String token, String password); UserPaylaodWeb resetPasswordByMail(String token, String password);

View File

@@ -626,7 +626,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee-1 where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF' and epa.id_impot_nature='IRF'
group by epa.ifu, group by epa.ifu,
@@ -643,7 +643,7 @@ BEGIN
epr.qip_parcelle, epr.qip_parcelle,
epr.exercice, epr.exercice,
sum(epr.montant_payer) as montant_rirf sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr from e_paiement_retenu epr
where epr.exercice=v_annee-1 where epr.exercice=v_annee-1
group by epr.ifu_retenue, group by epr.ifu_retenue,
epr.r_quartier, epr.r_quartier,

View File

@@ -340,7 +340,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee-1 where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF' and epa.id_impot_nature='IRF'
group by epa.ifu, group by epa.ifu,
@@ -357,7 +357,7 @@ BEGIN
epr.qip_parcelle, epr.qip_parcelle,
epr.exercice, epr.exercice,
sum(epr.montant_payer) as montant_rirf sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr from e_paiement_retenu epr
where epr.exercice=v_annee-1 where epr.exercice=v_annee-1
group by epr.ifu_retenue, group by epr.ifu_retenue,
epr.r_quartier, epr.r_quartier,

View File

@@ -639,7 +639,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee-1 where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF' and epa.id_impot_nature='IRF'
group by epa.ifu, group by epa.ifu,
@@ -656,7 +656,7 @@ BEGIN
epr.qip_parcelle, epr.qip_parcelle,
epr.exercice, epr.exercice,
sum(epr.montant_payer) as montant_rirf sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr from e_paiement_retenu epr
where epr.exercice=v_annee-1 where epr.exercice=v_annee-1
group by epr.ifu_retenue, group by epr.ifu_retenue,
epr.r_quartier, epr.r_quartier,

View File

@@ -296,7 +296,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee-1 where epa.exercice=v_annee-1
and epa.id_impot_nature='IRF' and epa.id_impot_nature='IRF'
group by epa.ifu, group by epa.ifu,
@@ -313,7 +313,7 @@ BEGIN
epr.qip_parcelle, epr.qip_parcelle,
epr.exercice, epr.exercice,
sum(epr.montant_payer) as montant_rirf sum(epr.montant_payer) as montant_rirf
from epaiement_retenu epr from e_paiement_retenu epr
where epr.exercice=v_annee-1 where epr.exercice=v_annee-1
group by epr.ifu_retenue, group by epr.ifu_retenue,
epr.r_quartier, epr.r_quartier,

View File

@@ -454,7 +454,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FB' and epa.id_impot_nature='FB'
group by epa.ifu, group by epa.ifu,

View File

@@ -455,7 +455,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FB' and epa.id_impot_nature='FB'
group by epa.ifu, group by epa.ifu,

View File

@@ -432,7 +432,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FB' and epa.id_impot_nature='FB'
group by epa.ifu, group by epa.ifu,

View File

@@ -433,7 +433,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FB' and epa.id_impot_nature='FB'
group by epa.ifu, group by epa.ifu,

View File

@@ -342,7 +342,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FNB' and epa.id_impot_nature='FNB'
group by epa.ifu, group by epa.ifu,

View File

@@ -180,7 +180,7 @@ BEGIN
epa.id_impot_nature, epa.id_impot_nature,
epa.exercice, epa.exercice,
sum(epa.montant_payer) as montant_acompte sum(epa.montant_payer) as montant_acompte
from epaiement_acompte epa from e_paiement_acompte epa
where epa.exercice=v_annee where epa.exercice=v_annee
and epa.id_impot_nature='FNB' and epa.id_impot_nature='FNB'
group by epa.ifu, group by epa.ifu,

View File

@@ -30,7 +30,7 @@ BEGIN
nup, nup,
exercice, exercice,
sum(montant_payer) as cumul_retenu sum(montant_payer) as cumul_retenu
from epaiement_retenu from e_paiement_retenu
where exercice = v_annee where exercice = v_annee
group by ifu_retenue, r_commune, r_quartier, group by ifu_retenue, r_commune, r_quartier,
qip_quartier, qip_ilot, qip_parcelle, qip_quartier, qip_ilot, qip_parcelle,
@@ -68,7 +68,7 @@ BEGIN
nup, nup,
exercice, exercice,
sum(montant_payer) as cumul_acompte sum(montant_payer) as cumul_acompte
from epaiement_acompte from e_paiement_acompte
where exercice = v_annee where exercice = v_annee
group by ifu, r_commune, r_quartier, group by ifu, r_commune, r_quartier,
qip_quartier, qip_ilot, qip_parcelle, qip_quartier, qip_ilot, qip_parcelle,

View File

@@ -450,8 +450,9 @@ public class MailService {
} }
@Async
public MailSendResponse sendValidationMail( //public MailSendResponse sendValidationMail(
public void sendValidationMail(
String recipientEmail, String recipientEmail,
String applicantName, String applicantName,
String eServicesNumber, String eServicesNumber,
@@ -484,7 +485,7 @@ public class MailService {
MailSendResponse.class MailSendResponse.class
); );
return response.getBody(); // return response.getBody();
} }