Skip to content

Instantly share code, notes, and snippets.

@rajeevshukla
Created May 1, 2020 04:32
Show Gist options
  • Save rajeevshukla/7ad8c90bb69952e2017d7b295931cb72 to your computer and use it in GitHub Desktop.
Save rajeevshukla/7ad8c90bb69952e2017d7b295931cb72 to your computer and use it in GitHub Desktop.
Form-Based Login success mapping
@RequestMapping("/formLoginSuccess")
public String getFormLoginInfo(Model model, @AuthenticationPrincipal Authentication authentication) {
// In form-based login flow you get UserDetails as principal while in Oauth based flow you get Oauth2User
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
model.addAttribute("name", userDetails.getUsername());
return "home";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment