From 6b9dcf24403186a81e7ccbb8c33c70f6cf28eb9e Mon Sep 17 00:00:00 2001 From: omenem Date: Wed, 4 Mar 2020 15:33:58 +0100 Subject: [PATCH] You nedd to verify your mail in onder to login --- .../smarthut/controller/AuthenticationController.java | 7 +++---- .../sanmarinoes/smarthut/models/JWTUserDetailsService.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/AuthenticationController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/AuthenticationController.java index c0c83c2..f0e8d7d 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/AuthenticationController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/AuthenticationController.java @@ -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); diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/JWTUserDetailsService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/JWTUserDetailsService.java index b20832b..06ee415 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/JWTUserDetailsService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/JWTUserDetailsService.java @@ -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 {