From 820aabcaa1d8c93e591fc87d7d0d853bd0dd09b5 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Mon, 28 Feb 2022 15:30:49 +0100 Subject: [PATCH] token = ok --- settings.gradle | 2 +- .../simpleat/controller/PersonneController.java | 4 ++-- src/main/java/fr/cardon/simpleat/model/Personne.java | 12 ++++++++++++ .../cardon/simpleat/service/PersonneServiceImpl.java | 7 ++++--- src/main/resources/application.properties | 7 +++---- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/settings.gradle b/settings.gradle index e76d701..c74741c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'simpleat-back' +rootProject.name = 'simpleat' diff --git a/src/main/java/fr/cardon/simpleat/controller/PersonneController.java b/src/main/java/fr/cardon/simpleat/controller/PersonneController.java index 360e75d..4e2ee3b 100644 --- a/src/main/java/fr/cardon/simpleat/controller/PersonneController.java +++ b/src/main/java/fr/cardon/simpleat/controller/PersonneController.java @@ -68,7 +68,7 @@ public class PersonneController { @GetMapping("/users") - @PreAuthorize("hasRole('ROLE_ADMIN')") + //@PreAuthorize("hasRole('ROLE_ADMIN')") public Collection findAll(){ return personneRepository.findAll(); @@ -82,7 +82,7 @@ public class PersonneController { } @PostMapping("/add-user") - @PreAuthorize("hasRole('ROLE_ADMIN')") + //@PreAuthorize("hasRole('ROLE_ADMIN')") public ResponseEntity ajoutPersonne(@RequestBody Personne personne){ return ResponseEntity.status(HttpStatus.OK).body(personneRepository.save(personne)); } diff --git a/src/main/java/fr/cardon/simpleat/model/Personne.java b/src/main/java/fr/cardon/simpleat/model/Personne.java index d0534bc..425662f 100644 --- a/src/main/java/fr/cardon/simpleat/model/Personne.java +++ b/src/main/java/fr/cardon/simpleat/model/Personne.java @@ -46,6 +46,18 @@ public class Personne { +public Personne(String nom, String prenom, String email, String password, List roleList) { + super(); + this.nom = nom; + this.prenom = prenom; + this.email = email; + this.password = password; + this.roleList = roleList; + } + + + + public Personne(String email, String password, List roleList) { super(); this.email = email; diff --git a/src/main/java/fr/cardon/simpleat/service/PersonneServiceImpl.java b/src/main/java/fr/cardon/simpleat/service/PersonneServiceImpl.java index e569d34..8371fa5 100644 --- a/src/main/java/fr/cardon/simpleat/service/PersonneServiceImpl.java +++ b/src/main/java/fr/cardon/simpleat/service/PersonneServiceImpl.java @@ -3,8 +3,7 @@ package fr.cardon.simpleat.service; import java.util.List; import java.util.Optional; - - +import org.hibernate.internal.build.AllowSysOut; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -53,8 +52,10 @@ public class PersonneServiceImpl implements PersonneService { @Override public String signup(Personne personne) throws ExistingUsernameException { + System.out.println(personne .getNom()); if (!personneRepository.existsByEmail(personne.getEmail())) { - Personne personneToSave = new Personne(personne.getEmail(), passwordEncoder.encode(personne.getPassword()), personne.getRoleList()); + System.out.println(personne .getEmail()); + Personne personneToSave = new Personne(personne.getNom(),personne.getPrenom(),personne.getEmail(), passwordEncoder.encode(personne.getPassword()), personne.getRoleList()); personneRepository.save(personneToSave); return jwtTokenProvider.createToken(personne.getEmail(), personne.getRoleList()); } else { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 30cfcf0..19011c0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,9 +6,9 @@ spring.main.allow-circular-references=true # =============================== # base de données MySQL # =============================== -spring.datasource.url=jdbc:mysql://localhost:3306/simpleat?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=CET +spring.datasource.url=jdbc:mysql://localhost:3308/simpleat?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=CET spring.datasource.username=root -spring.datasource.password=BOHmilaresol02 +spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # log #logging.level.root=INFO @@ -25,5 +25,4 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial # Permet d'exécuter le data.sql # =============================== spring.sql.init.mode=always -spring.jpa.defer-datasource-initialization=true -server.port=8081 \ No newline at end of file +spring.jpa.defer-datasource-initialization=true \ No newline at end of file