Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonononoki committed Jun 21, 2024
1 parent 35588dd commit 956b47c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ default List<User> usersSearch(UserSearchRequest request, Pageable page) {
request.getLikeIds(), request.getHideIds(), request.getBlockIds(), request.getGenderIds(), page);
}

List<User> findByConfirmedIsFalseAndDatesCreationDateBefore(Date date);
List<User> findByConfirmedIsFalseAndAdminFalseAndDatesCreationDateBefore(Date date);

@Query(value = "SELECT u FROM User u WHERE u.disabled = FALSE AND u.admin = FALSE AND u.confirmed = TRUE AND u.intention IS NOT NULL AND "
+ "u.locationLatitude IS NOT NULL AND u.locationLongitude IS NOT NULL AND u.profilePicture IS NOT NULL "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ public ModelAndView oauth2Facebook(@PathVariable String redirectUrlEncoded) {

@SuppressWarnings("rawtypes")
@GetMapping("/login/oauth2/success")
public ModelAndView oauth2Success()
throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, NoSuchAlgorithmException,
NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException, AlovoaException {
public ModelAndView oauth2Success() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ public String register(RegisterDto dto)
}

public void registerOauth(RegisterDto dto) throws MessagingException, IOException, AlovoaException,
NumberFormatException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException {
NumberFormatException {

String email = Tools.cleanEmail(authService.getOauth2Email());
if (email == null) {
Expand Down Expand Up @@ -210,8 +209,7 @@ public UserRegisterToken generateToken(User user) {
}

public User registerConfirm(String tokenString) throws MessagingException, IOException, AlovoaException,
NumberFormatException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException,
NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException {
NumberFormatException {
UserRegisterToken token = registerTokenRepo.findByContent(tokenString);

if (token == null) {
Expand All @@ -225,7 +223,7 @@ public User registerConfirm(String tokenString) throws MessagingException, IOExc
}

if (user.isConfirmed()) {
throw new AlovoaException("user_not_confirmed");
throw new AlovoaException("user_already_confirmed");
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void cleanNonConfirmedUsers(final Date date) {
ms -= nonConfirmedUsersCleanupDelay;
Date d = new Date(ms);

List<User> users = userRepo.findByConfirmedIsFalseAndDatesCreationDateBefore(d);
List<User> users = userRepo.findByConfirmedIsFalseAndAdminFalseAndDatesCreationDateBefore(d);

userRepo.deleteAll(users);
userRepo.flush();
Expand Down

0 comments on commit 956b47c

Please sign in to comment.