Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 17, 2024
1 parent b32f656 commit ee3dd87
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

import it.chalmers.gamma.app.apikey.ApiKeyFacade;
import it.chalmers.gamma.app.apikey.ApiKeySettingsFacade;
import it.chalmers.gamma.app.common.PrettyName.PrettyNameValidator;
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

@Controller
public class ApiKeyController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

import it.chalmers.gamma.app.client.ClientApprovalFacade;
import it.chalmers.gamma.app.client.ClientAuthorityFacade;
import it.chalmers.gamma.app.client.ClientFacade;
Expand All @@ -12,17 +15,13 @@
import it.chalmers.gamma.security.authentication.AuthenticationExtractor;
import it.chalmers.gamma.security.authentication.UserAuthentication;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;
import java.util.stream.Collectors;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

@Controller
public class ClientsController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

import it.chalmers.gamma.app.common.PrettyName.PrettyNameValidator;
import it.chalmers.gamma.app.group.GroupFacade;
import it.chalmers.gamma.app.post.PostFacade;
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import it.chalmers.gamma.app.user.UserFacade;
import it.chalmers.gamma.app.user.domain.Name.NameValidator;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
Expand All @@ -15,12 +20,6 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;
import java.util.stream.Collectors;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

@Controller
public class GroupsController {

Expand Down Expand Up @@ -436,7 +435,8 @@ public ModelAndView getNewMember(
return mv;
}

public ModelAndView createGetCreateGroup(boolean htmxRequest, GroupForm form, BindingResult bindingResult) {
public ModelAndView createGetCreateGroup(
boolean htmxRequest, GroupForm form, BindingResult bindingResult) {
ModelAndView mv = new ModelAndView();

if (htmxRequest) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;

import it.chalmers.gamma.app.common.Email.EmailValidator;
import it.chalmers.gamma.app.user.UserCreationFacade;
import it.chalmers.gamma.app.user.activation.domain.UserActivationRepository;
Expand All @@ -9,6 +11,7 @@
import it.chalmers.gamma.app.user.domain.LastName.LastNameValidator;
import it.chalmers.gamma.app.user.domain.Nick.NickValidator;
import it.chalmers.gamma.app.user.domain.UnencryptedPassword.UnencryptedPasswordValidator;
import java.time.Year;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
Expand All @@ -20,10 +23,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.time.Year;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;

@Controller
public class RegisterAccountController {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

import it.chalmers.gamma.app.common.PrettyName.PrettyNameValidator;
import it.chalmers.gamma.app.group.GroupFacade;
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import it.chalmers.gamma.app.supergroup.domain.SuperGroupRepository;
import it.chalmers.gamma.app.user.domain.Name.NameValidator;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;
import static it.chalmers.gamma.app.common.UUIDValidator.isValidUUID;

@Controller
public class SuperGroupsController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import it.chalmers.gamma.app.user.activation.domain.UserActivationToken;
import it.chalmers.gamma.app.user.domain.Cid;
import jakarta.transaction.Transactional;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;

import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;

@Service
public class UserActivationRepositoryAdapter implements UserActivationRepository {
Expand Down Expand Up @@ -57,11 +56,12 @@ public List<UserActivation> getAll() {
.toList();
}



@Override
public boolean isTokenValid(UserActivationToken token) {
return this.userActivationJpaRepository.findByToken(token.value()).map(this::isStillValid).orElse(false);
return this.userActivationJpaRepository
.findByToken(token.value())
.map(this::isStillValid)
.orElse(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import it.chalmers.gamma.app.user.passwordreset.domain.PasswordResetRepository;
import it.chalmers.gamma.app.user.passwordreset.domain.PasswordResetToken;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;

import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import org.springframework.stereotype.Service;

@Service("PasswordResetRepository")
@Transactional
Expand Down Expand Up @@ -65,7 +64,10 @@ public PasswordReset createNewToken(Cid cid) throws UserNotFoundException {

@Override
public boolean isTokenValid(PasswordResetToken token) {
return this.userPasswordResetJpaRepository.findByToken(token.value()).map(this::isStillValid).orElse(false);
return this.userPasswordResetJpaRepository
.findByToken(token.value())
.map(this::isStillValid)
.orElse(false);
}

@Override
Expand All @@ -91,5 +93,4 @@ public boolean isStillValid(UserPasswordResetEntity userPasswordResetEntity) {
Instant createdAt = userPasswordResetEntity.toDomain().createdAt();
return Duration.between(createdAt, Instant.now()).toMinutes() < 15;
}

}

0 comments on commit ee3dd87

Please sign in to comment.