Skip to content

Commit b34ba4f

Browse files
committed
work
1 parent d284984 commit b34ba4f

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/main/java/org/woehlke/java/simpleworklist/domain/db/user/account/UserAccountServiceImpl.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import org.woehlke.java.simpleworklist.domain.db.data.context.ContextRepository;
2121

2222
@Slf4j
23-
@Service("userAccountService")
24-
//@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
23+
@Service
24+
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
2525
public class UserAccountServiceImpl implements UserAccountService {
2626

2727
private final UserAccountRepository userAccountRepository;
@@ -30,7 +30,11 @@ public class UserAccountServiceImpl implements UserAccountService {
3030
private final PasswordEncoder encoder;
3131

3232
@Autowired
33-
public UserAccountServiceImpl(UserAccountRepository userAccountRepository, ChatMessageRepository userMessageRepository, ContextRepository contextRepository) {
33+
public UserAccountServiceImpl(
34+
UserAccountRepository userAccountRepository,
35+
ChatMessageRepository userMessageRepository,
36+
ContextRepository contextRepository
37+
) {
3438
this.userAccountRepository = userAccountRepository;
3539
this.userMessageRepository = userMessageRepository;
3640
this.contextRepository = contextRepository;
@@ -64,7 +68,7 @@ public void createUser(UserAccountForm userAccountForm) {
6468
}
6569

6670
@Override
67-
//@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
71+
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
6872
public UserAccount saveAndFlush(UserAccount u) {
6973
return userAccountRepository.saveAndFlush(u);
7074
}
@@ -80,7 +84,7 @@ public Page<UserAccount> findAll(Pageable request) {
8084
}
8185

8286
@Override
83-
//@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
87+
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
8488
public void changeUsersPassword(UserAccountForm userAccount) {
8589
UserAccount ua = userAccountRepository.findByUserEmail(userAccount.getUserEmail());
8690
if(ua != null) {
@@ -103,7 +107,8 @@ public Map<Long, Integer> getNewIncomingMessagesForEachOtherUser(UserAccount rec
103107
if(receiver.getId().longValue() == sender.getId().longValue()){
104108
newIncomingMessagesForEachOtherUser.put(sender.getId(),0);
105109
} else {
106-
List<UserAccountChatMessage> userAccountChatMessages = userMessageRepository.findBySenderAndReceiverAndReadByReceiver(sender,receiver,false);
110+
List<UserAccountChatMessage> userAccountChatMessages =
111+
userMessageRepository.findBySenderAndReceiverAndReadByReceiver(sender,receiver,false);
107112
newIncomingMessagesForEachOtherUser.put(sender.getId(), userAccountChatMessages.size());
108113
}
109114
}

src/main/java/org/woehlke/java/simpleworklist/domain/db/user/accountpassword/UserAccountPasswordServiceImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.springframework.beans.factory.annotation.Autowired;
5-
import org.springframework.security.authentication.AuthenticationManager;
65
import org.springframework.security.authentication.AuthenticationProvider;
76
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
87
import org.springframework.security.core.Authentication;
@@ -23,25 +22,24 @@ public class UserAccountPasswordServiceImpl implements UserAccountPasswordServic
2322

2423
private final UserAccountRepository userAccountRepository;
2524
private final PasswordEncoder encoder;
26-
//private final AuthenticationManager authenticationManager;
2725
private final AuthenticationProvider authenticationProvider;
2826

2927
@Autowired
3028
public UserAccountPasswordServiceImpl(
3129
UserAccountRepository userAccountRepository,
32-
//AuthenticationManager authenticationManager,
3330
AuthenticationProvider authenticationProvider
3431
) {
3532
this.userAccountRepository = userAccountRepository;
3633
this.authenticationProvider = authenticationProvider;
3734
int strength = 10;
3835
this.encoder = new BCryptPasswordEncoder(strength);
39-
//this.authenticationManager = authenticationManager;
4036
}
4137

4238
@Override
4339
public UserDetails updatePassword(UserDetails user, String newPassword) {
44-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword());
40+
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
41+
user.getUsername(), user.getPassword()
42+
);
4543
Authentication authenticationResult = authenticationProvider.authenticate(token);
4644
if (authenticationResult.isAuthenticated()) {
4745
UserAccount ua = userAccountRepository.findByUserEmail(user.getUsername());

0 commit comments

Comments
 (0)