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")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
//@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
public Collection<Personne> 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));
|
||||
}
|
||||
|
@ -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) {
|
||||
super();
|
||||
this.email = email;
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
spring.jpa.defer-datasource-initialization=true
|
Loading…
Reference in New Issue
Block a user