-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeController.java
43 lines (28 loc) · 1.08 KB
/
HomeController.java
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.example.demo.controller;
import java.security.Principal;
import java.util.Map;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HomeController {
// @GetMapping("/")
// public String home() {
// return "home";
// }
//
@GetMapping("/user")
public String user(@AuthenticationPrincipal OAuth2User principal) {
// Access user details from principal
// For example, principal.getAttribute("id"), principal.getAttribute("name"), etc.
// return "Welcome to the app";
return " Welcome user to fb";
}
// @GetMapping("/")
// public String home(Principal principal) {
// //Map<String,Object> details=(Map<String,Object>) ((OAuth2Authentication) principal).get
//
// return "welcome to fblogin";
}