backend-api #6
.gitea/workflows
.gitignoreMakefileMyINPulse-back
build.gradle
src
main
java
enseirb
myinpulse
MyinpulseApplication.java
api
config
postgres_db
controller
AdministrateursController.javaComptesRendusController.javaEntrepreneursController.javaProjetsController.javaRendezVousController.javaSectionsController.javaUtilisateursController.java
model
Administrateurs.javaComptesRendus.javaEntrepreneurs.javaProjets.javaRendezVous.javaSections.javaUtilisateurs.java
repository
security
resources
test
java
enseirb
myinpulse
config
backdev.docker-compose.yamlbackdev.envbackdev.front.envbackdev.main.envfrontdev.docker-compose.yamlfrontdev.envfrontdev.front.envfrontdev.main.envprod.docker-compose.yamlprod.envprod.front.envprod.main.env
front/MyINPulse-front/src/components
postgres
@ -1,43 +1,24 @@
|
||||
package enseirb.myinpulse.api;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class GetUserInfo {
|
||||
// TODO: understand how to get data
|
||||
@GetMapping("/getUserInfo")
|
||||
public Object user(Principal principal) {
|
||||
System.out.println("GetUserInfo + " + principal);
|
||||
System.out.println(SecurityContextHolder.getContext().getAuthentication());
|
||||
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random")
|
||||
@GetMapping("/unauth/random")
|
||||
public boolean rand() {
|
||||
System.err.println("HELLO");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random2")
|
||||
@GetMapping("/admin/random")
|
||||
public boolean rand2() {
|
||||
System.err.println("HELLO2");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random3")
|
||||
@GetMapping("/entrepreneur/random")
|
||||
public boolean rand3() {
|
||||
System.err.println("HELLO");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user