Merge branch '18-username-not-enable-can-login' into 'dev'
Resolve "Username not enable can login" Closes #18 See merge request sa4-2020/the-sanmarinoes/backend!23
This commit is contained in:
commit
bff433e954
2 changed files with 4 additions and 5 deletions
|
@ -55,9 +55,6 @@ public class AuthenticationController {
|
|||
throw new UserNotFoundException();
|
||||
}
|
||||
|
||||
System.out.println(user);
|
||||
System.out.println(authenticationRequest);
|
||||
|
||||
authenticate(user.getUsername(), authenticationRequest.getPassword());
|
||||
userDetails = userDetailsService.loadUserByUsername(user.getUsername());
|
||||
} else {
|
||||
|
@ -65,7 +62,9 @@ public class AuthenticationController {
|
|||
authenticate(
|
||||
authenticationRequest.getUsernameOrEmail(),
|
||||
authenticationRequest.getPassword());
|
||||
userDetails = userDetailsService.loadUserByUsername(authenticationRequest.getUsernameOrEmail());
|
||||
userDetails =
|
||||
userDetailsService.loadUserByUsername(
|
||||
authenticationRequest.getUsernameOrEmail());
|
||||
}
|
||||
|
||||
final String token = jwtTokenUtil.generateToken(userDetails);
|
||||
|
|
|
@ -15,7 +15,7 @@ public class JWTUserDetailsService implements UserDetailsService {
|
|||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
User toReturn = repository.findByUsername(username);
|
||||
if (toReturn != null) {
|
||||
if (toReturn != null && toReturn.getEnabled()) {
|
||||
return new org.springframework.security.core.userdetails.User(
|
||||
toReturn.getUsername(), toReturn.getPassword(), Set.of());
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue