AuthenticationService.java line 43 - Double call to the database
opened this issue · comments
Deleted user commented
You can retrieve the user details from the authentication object instead of making another call to the database:
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(
request.getUsernameOrEmail(),
request.getPassword()
)
);
var user = (User) authentication.getPrincipal();
var jwtToken = jwtService.generateJwt(user);
Ryan commented
Thank you! I also jsut discovered this.
BOUALI Ali commented
yes that's true.
As I mentioned, it is just a sample project to show how to implement JWT security with Spring boot