@RequestParam("user") String username,
@RequestParam("password") String password,
HttpServletRequest request, HttpServletResponse response) {
Authentication token =
new UsernamePasswordAuthenticationToken(username, password);
LoginDetail loginDetail = new LoginDetail();
try {
Authentication authentication = authenticationManager.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(authentication);
//return new LoginDetail().success().principal(authentication.getName());
//return loginDetail;
loginDetail.setUsername(authentication.getName());
//loginDetail.setRole(authentication.getAuthorities());
loginDetail.setStatus(true);
} catch (BadCredentialsException ex) {
//return "{\"status\": false, \"error\": \"Bad Credentials\"}";
loginDetail.setError(ex.toString());
}
return loginDetail;
}