gestion creation user
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 39s

This commit is contained in:
2026-07-03 19:55:36 +01:00
parent 8fa74a7fef
commit 9e535bc0e7
16 changed files with 42 additions and 34 deletions

View File

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

View File

@@ -95,7 +95,7 @@ public class DemandeReinitialisationMPServiceImpl implements DemandeReinitialisa
if (demandeReinitialisationMPOptional.isPresent()) {
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPOptional.get();
User user = demandeReinitialisationMP.getUser();
userService.resetPassword(user.getUsername());
// userService.resetPassword(user.getUsername());
demandeReinitialisationMP.setEtatDemande(EtatDemande.TRAITE);
return demandeReinitialisationMPRepository.save(demandeReinitialisationMP);
} 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.user.User;
import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.exceptions.ApplicationException;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
@@ -245,15 +246,23 @@ public class UserServiceImpl implements UserService {
}
@Override
public UserPaylaodWeb resetPassword(String username) {
public UserPaylaodWeb requestResetPassword(String username) {
User user = userRepository.findByUsername(username).orElseThrow(() -> new NotFoundException(
String.format("L'utilisateur %s n'existe pas.", username)
));
String password = stringService.generatePassword();
user.setPassword(passwordEncoder.encode(password));
user.setResetPassword(true);
user.setTokenDate(LocalDateTime.now());
String token= stringService.getUniqueString();
user.setToken(token);
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());
return optionalUserPaylaodWeb.orElse(null);
}
@@ -266,7 +275,6 @@ public class UserServiceImpl implements UserService {
user.setPassword(passwordEncoder.encode(password));
user.setResetPassword(false);
user= userRepository.save(user);
// mailService.sendAccountReinitMail(user,password);
Optional<UserPaylaodWeb> optionalUserPaylaodWeb = userRepository.findUserToDtoById(user.getId());
return optionalUserPaylaodWeb.orElse(null);
}
@@ -347,13 +355,12 @@ public class UserServiceImpl implements UserService {
public Boolean validationTokenResetPassword(String token) {
Optional<User> optionalUser=userRepository.findByToken(token);
if(optionalUser.isEmpty()){
return false;
throw new ApplicationException("Token invalide") ;
}
LocalDateTime tokenDate= optionalUser.get().getTokenDate();
if(isTokenExpired(tokenDate)){
return false ;
throw new ApplicationException("Token expiré") ;
}
return true;
}
@@ -380,7 +387,7 @@ public class UserServiceImpl implements UserService {
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 disactivateUser(Long id);
UserPaylaodWeb resetPassword(String username);
UserPaylaodWeb requestResetPassword(String username);
UserPaylaodWeb resetPasswordByMail(String token, String password);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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