Created
January 7, 2018 14:35
-
-
Save slmanju/eb0a38b38bffd7e341dd9ee94f92a994 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RestController | |
| public class LoginController { | |
| @Autowired | |
| private AuthenticationManager authenticationManager; | |
| @PostMapping("/token") | |
| public ResponseEntity<?> authenticate(@RequestBody LoginDto loginDto) { | |
| // Perform the authentication | |
| UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( | |
| loginDto.getUsername(), | |
| loginDto.getPassword() | |
| ); | |
| Authentication authentication = this.authenticationManager.authenticate(authenticationToken); | |
| SecurityContextHolder.getContext().setAuthentication(authentication); | |
| return ResponseEntity.ok(TokenDto.builder().token("winteriscoming").build()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment