develop #279

Merged
judaur2005 merged 3 commits from develop into main 2026-07-28 16:35:49 +00:00
3 changed files with 31 additions and 30 deletions
Showing only changes of commit 3b6a757c43 - Show all commits

View File

@@ -70,34 +70,34 @@ public class UserController {
}
}
// @PostMapping("/change-password")
// @PreAuthorize("hasAuthority('UPDATE_USER')")
// public ResponseEntity<?> changeUserPassword(@RequestBody Login login) {
// try {
// userService.updatePassword(login.getUsername(), login.getPassword());
// return new ResponseEntity<>(
// new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
@PostMapping("/change-password")
@PreAuthorize("hasAuthority('UPDATE_USER')")
public ResponseEntity<?> changeUserPassword(@RequestBody Login login) {
try {
userService.updatePassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>(
new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PostMapping("/change-my-password")
@PreAuthorize("hasAuthority('UPDATE_USER')")
@PreAuthorize("hasAuthority('CHANGE_MY_PASSWORD')")
public ResponseEntity<?> changeMyPassword(@CurrentUser UserPrincipal currentUser, @RequestBody Login login) {
try {
User user = currentUser.getUser() ;

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.enums;
public enum UserRole {
VALIDE_ENQUETE,
APPROVAL_AVIS,
CHANGE_MY_PASSWORD,
CREATE_ARRONDISSEMENT,
READ_ARRONDISSEMENT,
UPDATE_ARRONDISSEMENT,

View File

@@ -24,7 +24,7 @@ public class UserPaylaodWeb {
private Long structureId;
private String structureCode;
private String structureNom;
private Boolean actif;
private Boolean active;
private Boolean resetPassword;
public UserPaylaodWeb(Long id,
@@ -36,7 +36,7 @@ public class UserPaylaodWeb {
Long structureId,
String structureCode,
String structureNom,
Boolean actif,
Boolean active,
Boolean resetPassword) {
this.id = id;
this.nom = nom;
@@ -47,7 +47,7 @@ public class UserPaylaodWeb {
this.structureId = structureId;
this.structureCode = structureCode;
this.structureNom = structureNom;
this.actif = actif;
this.active = active;
this.resetPassword = resetPassword;
}
}