forked from NeilAlishev/SpringCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloController.java
More file actions
27 lines (23 loc) · 874 Bytes
/
HelloController.java
File metadata and controls
27 lines (23 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package ru.alishev.springcourse.FirstSecurityApp.controllers;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import ru.alishev.springcourse.FirstSecurityApp.security.PersonDetails;
/**
* @author Neil Alishev
*/
@Controller
public class HelloController {
@GetMapping("/hello")
public String sayHello() {
return "hello";
}
@GetMapping("/showUserInfo")
public String showUserInfo() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
PersonDetails personDetails = (PersonDetails) authentication.getPrincipal();
System.out.println(personDetails.getPerson());
return "hello";
}
}