diff --git a/src/main/java/com/tikelespike/nilee/security/AuthenticatedUser.java b/src/main/java/com/tikelespike/nilee/security/AuthenticatedUser.java index c42326c..f89d4ee 100644 --- a/src/main/java/com/tikelespike/nilee/security/AuthenticatedUser.java +++ b/src/main/java/com/tikelespike/nilee/security/AuthenticatedUser.java @@ -20,6 +20,7 @@ public AuthenticatedUser(AuthenticationContext authenticationContext, UserReposi this.authenticationContext = authenticationContext; } + @Transactional public Optional get() { return authenticationContext.getAuthenticatedUser(UserDetails.class) .map(userDetails -> userRepository.findByUsername(userDetails.getUsername())); diff --git a/src/main/java/com/tikelespike/nilee/security/UserDetailsServiceImpl.java b/src/main/java/com/tikelespike/nilee/security/UserDetailsServiceImpl.java index 216ae8c..5f5b06b 100644 --- a/src/main/java/com/tikelespike/nilee/security/UserDetailsServiceImpl.java +++ b/src/main/java/com/tikelespike/nilee/security/UserDetailsServiceImpl.java @@ -21,6 +21,7 @@ public UserDetailsServiceImpl(UserRepository userRepository) { this.userRepository = userRepository; } + @Transactional @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username);