diff --git a/src/main/java/com/nonononoki/alovoa/component/AuthProvider.java b/src/main/java/com/nonononoki/alovoa/component/AuthProvider.java index c65019e3..8c2c51b9 100644 --- a/src/main/java/com/nonononoki/alovoa/component/AuthProvider.java +++ b/src/main/java/com/nonononoki/alovoa/component/AuthProvider.java @@ -66,9 +66,6 @@ public Authentication authenticate(Authentication authentication) throws Authent if (user == null) { throw new BadCredentialsException(""); } - if (user.isDisabled()) { - throw new DisabledException(""); - } if (password.isEmpty()) { throw new BadCredentialsException(""); diff --git a/src/main/java/com/nonononoki/alovoa/html/ApiResource.java b/src/main/java/com/nonononoki/alovoa/html/ApiResource.java index e747536c..b67a17b2 100644 --- a/src/main/java/com/nonononoki/alovoa/html/ApiResource.java +++ b/src/main/java/com/nonononoki/alovoa/html/ApiResource.java @@ -194,10 +194,6 @@ public Map resourceProfileView(@PathVariable UUID uuid) throws throw new AlovoaException(ExceptionHandler.USER_NOT_FOUND); } - if (userView.isDisabled()) { - throw new AlovoaException(ExceptionHandler.USER_NOT_FOUND); - } - ModelMap map = new ModelMap(); userView = userRepo.saveAndFlush(userView); diff --git a/src/main/java/com/nonononoki/alovoa/model/UserGdpr.java b/src/main/java/com/nonononoki/alovoa/model/UserGdpr.java index f359fdb5..1dcbd03b 100644 --- a/src/main/java/com/nonononoki/alovoa/model/UserGdpr.java +++ b/src/main/java/com/nonononoki/alovoa/model/UserGdpr.java @@ -11,8 +11,6 @@ @Data public class UserGdpr { - private boolean confirmed; - private boolean disabled; private int preferedMinAge; private int preferedMaxAge; private Double locationLatitude; @@ -41,8 +39,6 @@ public class UserGdpr { public static UserGdpr userToUserGdpr(User user) { UserGdpr u = new UserGdpr(); - u.setConfirmed(user.isConfirmed()); - u.setDisabled(user.isDisabled()); u.setPreferedMinAge(user.getPreferedMinAge()); u.setPreferedMaxAge(user.getPreferedMaxAge()); u.setTotalDonations(user.getTotalDonations()); diff --git a/src/main/java/com/nonononoki/alovoa/repo/UserDonationRepository.java b/src/main/java/com/nonononoki/alovoa/repo/UserDonationRepository.java index 59813b15..8aaaec26 100644 --- a/src/main/java/com/nonononoki/alovoa/repo/UserDonationRepository.java +++ b/src/main/java/com/nonononoki/alovoa/repo/UserDonationRepository.java @@ -8,6 +8,6 @@ import com.nonononoki.alovoa.entity.user.UserDonation; public interface UserDonationRepository extends JpaRepository { - List findTop20ByUserDatesDateOfBirthGreaterThanEqualAndUserDatesDateOfBirthLessThanEqualOrderByDateDesc(Date minDate, Date maxDate); + List findTop20ByUserDisabledFalseAndUserDatesDateOfBirthGreaterThanEqualAndUserDatesDateOfBirthLessThanEqualOrderByDateDesc(Date minDate, Date maxDate); } diff --git a/src/main/java/com/nonononoki/alovoa/service/AdminService.java b/src/main/java/com/nonononoki/alovoa/service/AdminService.java index 227aa4ac..e560820f 100644 --- a/src/main/java/com/nonononoki/alovoa/service/AdminService.java +++ b/src/main/java/com/nonononoki/alovoa/service/AdminService.java @@ -140,46 +140,7 @@ public void banUser(UUID uuid) throws AlovoaException, NumberFormatException { throw new AlovoaException("user_is_admin"); } - UserDeleteParams userDeleteParam = UserDeleteParams.builder().conversationRepo(conversationRepo) - .userBlockRepo(userBlockRepo).userHideRepo(userHideRepo).userLikeRepo(userLikeRepo) - .userNotificationRepo(userNotificationRepo).userRepo(userRepo).userReportRepo(userReportRepo) - .userVerificationPictureRepo(userVerificationPictureRepo).build(); - - try { - UserService.removeUserDataCascading(user, userDeleteParam); - } catch (Exception e) { - logger.warn(ExceptionUtils.getStackTrace(e)); - } - - user = userRepo.findByEmail(user.getEmail()); - - user.setAudio(null); - user.setDates(null); - user.setDeleteToken(null); - user.setDescription(null); - user.setLanguage(null); - user.setCountry(null); user.setDisabled(true); - user.getDonations().clear(); - user.setFirstName(null); - user.setGender(null); - user.getImages().clear(); - user.setIntention(null); - user.getInterests().clear(); - user.setLocationLatitude(null); - user.setLocationLongitude(null); - user.setPassword(null); - user.setPasswordToken(null); - user.setPreferedGenders(null); - user.setPreferedMaxAge(0); - user.setPreferedMinAge(0); - user.setRegisterToken(null); - user.setTotalDonations(0); - user.setProfilePicture(null); - user.setVerificationCode(null); - user.setVerificationPicture(null); - user.setShowZodiac(false); - user.getPrompts().clear(); userRepo.saveAndFlush(user); } @@ -199,10 +160,6 @@ public void deleteAccount(AdminAccountDeleteDto dto) throws AlovoaException { throw new AlovoaException(ExceptionHandler.USER_NOT_FOUND); } - if (user.isDisabled()) { - throw new AlovoaException("user_is_banned"); - } - if (user.isAdmin()) { throw new AlovoaException("cannot_delete_admin"); } diff --git a/src/main/java/com/nonononoki/alovoa/service/AuthService.java b/src/main/java/com/nonononoki/alovoa/service/AuthService.java index 2cb071ba..75a7ca1c 100644 --- a/src/main/java/com/nonononoki/alovoa/service/AuthService.java +++ b/src/main/java/com/nonononoki/alovoa/service/AuthService.java @@ -41,16 +41,9 @@ public User getCurrentUser(boolean throwExceptionWhenNull) throws AlovoaExceptio } User user = userRepo.findByEmail(Tools.cleanEmail(email)); - if (user != null && user.isDisabled()) { + if (user == null) { throw new AlovoaException(ExceptionHandler.USER_NOT_FOUND); - } else if (user == null && throwExceptionWhenNull) { - //try again - user = userRepo.findByEmail(Tools.cleanEmail(email)); - if (user == null) { - throw new AlovoaException(ExceptionHandler.USER_NOT_FOUND); - } } - return user; } diff --git a/src/main/java/com/nonononoki/alovoa/service/DonateService.java b/src/main/java/com/nonononoki/alovoa/service/DonateService.java index 2063bba7..344ddf51 100644 --- a/src/main/java/com/nonononoki/alovoa/service/DonateService.java +++ b/src/main/java/com/nonononoki/alovoa/service/DonateService.java @@ -88,7 +88,7 @@ public List filter(int filter) throws AlovoaException, InvalidKeyEx if (filter == FILTER_RECENT) { donationsToDtos = DonationDto.donationsToDtos(userDonationRepo - .findTop20ByUserDatesDateOfBirthGreaterThanEqualAndUserDatesDateOfBirthLessThanEqualOrderByDateDesc( + .findTop20ByUserDisabledFalseAndUserDatesDateOfBirthGreaterThanEqualAndUserDatesDateOfBirthLessThanEqualOrderByDateDesc( minDate, maxDate), user, userService, textEncryptor, maxEntries, ignoreIntention); } else if (filter == FILTER_AMOUNT) { diff --git a/src/main/java/com/nonononoki/alovoa/service/PasswordService.java b/src/main/java/com/nonononoki/alovoa/service/PasswordService.java index ba5eb262..eb892330 100644 --- a/src/main/java/com/nonononoki/alovoa/service/PasswordService.java +++ b/src/main/java/com/nonononoki/alovoa/service/PasswordService.java @@ -83,10 +83,6 @@ public UserPasswordToken resetPassword(PasswordResetDto dto) throw new AlovoaException("user_has_social_login"); } - if (u.isDisabled()) { - throw new AlovoaException("user_disabled"); - } - UserPasswordToken token = new UserPasswordToken(); token.setContent(RandomStringUtils.random(tokenLength, 0, 0, true, true, null, new SecureRandom())); token.setDate(new Date()); diff --git a/src/main/java/com/nonononoki/alovoa/service/UserService.java b/src/main/java/com/nonononoki/alovoa/service/UserService.java index 05e2a119..4d1def8a 100644 --- a/src/main/java/com/nonononoki/alovoa/service/UserService.java +++ b/src/main/java/com/nonononoki/alovoa/service/UserService.java @@ -739,17 +739,17 @@ public void likeUser(UUID uuid, String message) throws AlovoaException { like.setUserTo(user); currUser.getLikes().add(like); - UserNotification not = new UserNotification(); - not.setContent(UserNotification.USER_LIKE); - not.setDate(new Date()); - not.setUserFrom(currUser); - not.setUserTo(user); - not.setMessage(message); - currUser.getNotifications().add(not); - - user.getDates().setNotificationDate(new Date()); - - currUser.getHiddenUsers().removeIf(hide -> hide.getUserTo().getId().equals(user.getId())); + if (!currUser.isDisabled()) { + UserNotification not = new UserNotification(); + not.setContent(UserNotification.USER_LIKE); + not.setDate(new Date()); + not.setUserFrom(currUser); + not.setUserTo(user); + not.setMessage(message); + currUser.getNotifications().add(not); + user.getDates().setNotificationDate(new Date()); + currUser.getHiddenUsers().removeIf(hide -> hide.getUserTo().getId().equals(user.getId())); + } userRepo.saveAndFlush(user); userRepo.saveAndFlush(currUser); @@ -757,7 +757,7 @@ public void likeUser(UUID uuid, String message) throws AlovoaException { final boolean isMatch = user.getLikes().stream().filter(o -> o.getUserTo().getId() != null) .anyMatch(o -> o.getUserTo().getId().equals(currUser.getId())); - if (isMatch) { + if (!currUser.isDisabled() && isMatch) { Conversation convo = new Conversation(); convo.setUsers(new ArrayList<>()); convo.setDate(new Date()); @@ -777,7 +777,7 @@ public void likeUser(UUID uuid, String message) throws AlovoaException { mailService.sendMatchNotificationMail(user); } - } else if (user.getUserSettings().isEmailLike()) { + } else if (!currUser.isDisabled() && user.getUserSettings().isEmailLike()) { mailService.sendLikeNotificationMail(user); } }