backend-api #6
@ -1,43 +1,24 @@
|
|||||||
package enseirb.myinpulse.api;
|
package enseirb.myinpulse.api;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
|
|
||||||
import java.security.Principal;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
public class GetUserInfo {
|
public class GetUserInfo {
|
||||||
// TODO: understand how to get data
|
@GetMapping("/unauth/random")
|
||||||
@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")
|
|
||||||
public boolean rand() {
|
public boolean rand() {
|
||||||
System.err.println("HELLO");
|
|
||||||
return Math.random() > 0.5;
|
return Math.random() > 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
@GetMapping("/admin/random")
|
||||||
@GetMapping("/random2")
|
|
||||||
public boolean rand2() {
|
public boolean rand2() {
|
||||||
System.err.println("HELLO2");
|
|
||||||
return Math.random() > 0.5;
|
return Math.random() > 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
@GetMapping("/entrepreneur/random")
|
||||||
@GetMapping("/random3")
|
|
||||||
public boolean rand3() {
|
public boolean rand3() {
|
||||||
System.err.println("HELLO");
|
|
||||||
return Math.random() > 0.5;
|
return Math.random() > 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user