Merge pull request #7 from HideyoshiNakazone/changes-api-delete-endpoints
Changes Api DELETE Endpoints and Fixes Minor Bugs
This commit is contained in:
37
.github/workflows/docker-image.yml
vendored
37
.github/workflows/docker-image.yml
vendored
@@ -7,45 +7,10 @@ on:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:11
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: portfolio
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Build with Maven
|
||||
env:
|
||||
FRONT_END_PATH: 'localhost:5000'
|
||||
FRONT_END_CONNECTION_TYPE: 'unsecure'
|
||||
PORT: 8070
|
||||
DATABASE_URL: 'postgresql://localhost:5432/portfolio'
|
||||
DATABASE_USER: 'postgres'
|
||||
DATABASE_PASSWORD: 'postgres'
|
||||
run: ./mvnw -B package --file pom.xml
|
||||
|
||||
docker:
|
||||
|
||||
needs: run-tests
|
||||
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
|
||||
20
.github/workflows/run-tests.yml
vendored
Normal file
20
.github/workflows/run-tests.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: ci
|
||||
on:
|
||||
push
|
||||
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Running Tests with Maven
|
||||
run: ./mvnw test
|
||||
2
pom.xml
2
pom.xml
@@ -55,7 +55,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.5.0</version>
|
||||
<version>42.5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -8,9 +8,9 @@ public enum OAuthMapEnum {
|
||||
|
||||
GITHUB(GithubOAuthMap.class, Provider.GITHUB);
|
||||
|
||||
private Class oAuthMap;
|
||||
private final Class oAuthMap;
|
||||
|
||||
private Provider provider;
|
||||
private final Provider provider;
|
||||
|
||||
private OAuthMapEnum(Class oAuthMap, Provider provider) {
|
||||
this.oAuthMap = oAuthMap;
|
||||
|
||||
@@ -27,7 +27,6 @@ public class OAuthRequestRepository implements AuthorizationRequestRepository<OA
|
||||
public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
String state = authorizationRequest.getState();
|
||||
log.info(state);
|
||||
|
||||
request.getSession().setAttribute(
|
||||
String.format("state_%s", state),
|
||||
|
||||
@@ -6,10 +6,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@@ -26,7 +23,7 @@ public class SessionController {
|
||||
return ResponseEntity.ok(this.sessionManagerService.validateSession(session));
|
||||
}
|
||||
|
||||
@PostMapping(path="/destroy")
|
||||
@DeleteMapping(path="/destroy")
|
||||
public ResponseEntity<Void> destroyCurrentSession(HttpSession session) {
|
||||
this.sessionManagerService.destroySession(session);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class UserController {
|
||||
response.sendRedirect("http://localhost:4200");
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@UserResourceGuard(accessType = UserResourceGuardEnum.SAME_USER)
|
||||
public ResponseEntity<Void> deleteUser(@PathVariable("id") Long id) {
|
||||
this.userService.deleteUser(id);
|
||||
|
||||
@@ -4,15 +4,14 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
||||
|
||||
private Pattern pattern;
|
||||
private Matcher matcher;
|
||||
private static final String EMAIL_PATTERN = "^[_A-Za-z\\d-+]+(.[_A-Za-z\\d-]+)*@+[A-Za-z\\d-]+(.[A-Za-z\\d]+)*(.[A-Za-z]{2,})$";
|
||||
private static final String EMAIL_PATTERN = "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$";
|
||||
|
||||
@Override
|
||||
public void initialize(ValidEmail constraintAnnotation) {
|
||||
@@ -24,8 +23,12 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
||||
}
|
||||
|
||||
private boolean validateEmail(String email) {
|
||||
pattern = Pattern.compile(EMAIL_PATTERN);
|
||||
matcher = pattern.matcher(email);
|
||||
if (Objects.isNull(email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(EMAIL_PATTERN);
|
||||
Matcher matcher = pattern.matcher(email);
|
||||
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user