token = ok
This commit is contained in:
parent
c8d9cd4db8
commit
820aabcaa1
@ -1 +1 @@
|
|||||||
rootProject.name = 'simpleat-back'
|
rootProject.name = 'simpleat'
|
||||||
|
@ -68,7 +68,7 @@ public class PersonneController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/users")
|
@GetMapping("/users")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
public Collection<Personne> findAll(){
|
public Collection<Personne> findAll(){
|
||||||
|
|
||||||
return personneRepository.findAll();
|
return personneRepository.findAll();
|
||||||
@ -82,7 +82,7 @@ public class PersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add-user")
|
@PostMapping("/add-user")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
//@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
public ResponseEntity<?> ajoutPersonne(@RequestBody Personne personne){
|
public ResponseEntity<?> ajoutPersonne(@RequestBody Personne personne){
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(personneRepository.save(personne));
|
return ResponseEntity.status(HttpStatus.OK).body(personneRepository.save(personne));
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,18 @@ public class Personne {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Personne(String nom, String prenom, String email, String password, List<EnumRole> roleList) {
|
||||||
|
super();
|
||||||
|
this.nom = nom;
|
||||||
|
this.prenom = prenom;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.roleList = roleList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Personne(String email, String password, List<EnumRole> roleList) {
|
public Personne(String email, String password, List<EnumRole> roleList) {
|
||||||
super();
|
super();
|
||||||
this.email = email;
|
this.email = email;
|
||||||
|
@ -3,8 +3,7 @@ package fr.cardon.simpleat.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.hibernate.internal.build.AllowSysOut;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
@ -53,8 +52,10 @@ public class PersonneServiceImpl implements PersonneService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String signup(Personne personne) throws ExistingUsernameException {
|
public String signup(Personne personne) throws ExistingUsernameException {
|
||||||
|
System.out.println(personne .getNom());
|
||||||
if (!personneRepository.existsByEmail(personne.getEmail())) {
|
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);
|
personneRepository.save(personneToSave);
|
||||||
return jwtTokenProvider.createToken(personne.getEmail(), personne.getRoleList());
|
return jwtTokenProvider.createToken(personne.getEmail(), personne.getRoleList());
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,9 +6,9 @@ spring.main.allow-circular-references=true
|
|||||||
# ===============================
|
# ===============================
|
||||||
# base de données MySQL
|
# 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.username=root
|
||||||
spring.datasource.password=BOHmilaresol02
|
spring.datasource.password=root
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
# log
|
# log
|
||||||
#logging.level.root=INFO
|
#logging.level.root=INFO
|
||||||
@ -26,4 +26,3 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial
|
|||||||
# ===============================
|
# ===============================
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
spring.jpa.defer-datasource-initialization=true
|
spring.jpa.defer-datasource-initialization=true
|
||||||
server.port=8081
|
|
Loading…
Reference in New Issue
Block a user