RLH-3 - Implement account deletion logic
This commit is contained in:
parent
2f6d4a9f1b
commit
c5315daf41
@ -12,4 +12,6 @@ public interface UserService
|
||||
User loadUserByUsername(String username) throws UsernameNotFoundException;
|
||||
|
||||
User loadUserByEmail(String email) throws UsernameNotFoundException;
|
||||
|
||||
void deleteUser(String email);
|
||||
}
|
||||
|
@ -31,4 +31,12 @@ public class UserServiceImpl implements UserService
|
||||
public User loadUserByEmail(String email) throws UsernameNotFoundException {
|
||||
return userRepository.findByEmail(email).orElseThrow(() -> new UsernameNotFoundException(email));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String email) {
|
||||
if (userRepository.findByEmail(email).isEmpty()) {
|
||||
throw new UsernameNotFoundException(email);
|
||||
}
|
||||
userRepository.delete(userRepository.findByEmail(email).get());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user