Merge pull request #7 from HideyoshiNakazone/changes-api-delete-endpoints
Changes Api DELETE Endpoints and Fixes Minor Bugs
This commit is contained in:
39
.github/workflows/docker-image.yml
vendored
39
.github/workflows/docker-image.yml
vendored
@@ -6,46 +6,11 @@ on:
|
|||||||
- 'main'
|
- 'main'
|
||||||
|
|
||||||
jobs:
|
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:
|
docker:
|
||||||
|
|
||||||
|
needs: run-tests
|
||||||
needs: [build]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>42.5.0</version>
|
<version>42.5.1</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ public enum OAuthMapEnum {
|
|||||||
|
|
||||||
GITHUB(GithubOAuthMap.class, Provider.GITHUB);
|
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) {
|
private OAuthMapEnum(Class oAuthMap, Provider provider) {
|
||||||
this.oAuthMap = oAuthMap;
|
this.oAuthMap = oAuthMap;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class OAuthRequestRepository implements AuthorizationRequestRepository<OA
|
|||||||
public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, HttpServletResponse response) {
|
public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
String state = authorizationRequest.getState();
|
String state = authorizationRequest.getState();
|
||||||
log.info(state);
|
|
||||||
|
|
||||||
request.getSession().setAttribute(
|
request.getSession().setAttribute(
|
||||||
String.format("state_%s", state),
|
String.format("state_%s", state),
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
@@ -26,7 +23,7 @@ public class SessionController {
|
|||||||
return ResponseEntity.ok(this.sessionManagerService.validateSession(session));
|
return ResponseEntity.ok(this.sessionManagerService.validateSession(session));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path="/destroy")
|
@DeleteMapping(path="/destroy")
|
||||||
public ResponseEntity<Void> destroyCurrentSession(HttpSession session) {
|
public ResponseEntity<Void> destroyCurrentSession(HttpSession session) {
|
||||||
this.sessionManagerService.destroySession(session);
|
this.sessionManagerService.destroySession(session);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class UserController {
|
|||||||
response.sendRedirect("http://localhost:4200");
|
response.sendRedirect("http://localhost:4200");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@UserResourceGuard(accessType = UserResourceGuardEnum.SAME_USER)
|
@UserResourceGuard(accessType = UserResourceGuardEnum.SAME_USER)
|
||||||
public ResponseEntity<Void> deleteUser(@PathVariable("id") Long id) {
|
public ResponseEntity<Void> deleteUser(@PathVariable("id") Long id) {
|
||||||
this.userService.deleteUser(id);
|
this.userService.deleteUser(id);
|
||||||
|
|||||||
@@ -4,15 +4,14 @@ import lombok.RequiredArgsConstructor;
|
|||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
import javax.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
||||||
|
|
||||||
private Pattern pattern;
|
private static final String EMAIL_PATTERN = "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$";
|
||||||
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,})$";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ValidEmail constraintAnnotation) {
|
public void initialize(ValidEmail constraintAnnotation) {
|
||||||
@@ -24,8 +23,12 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateEmail(String email) {
|
private boolean validateEmail(String email) {
|
||||||
pattern = Pattern.compile(EMAIL_PATTERN);
|
if (Objects.isNull(email)) {
|
||||||
matcher = pattern.matcher(email);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern pattern = Pattern.compile(EMAIL_PATTERN);
|
||||||
|
Matcher matcher = pattern.matcher(email);
|
||||||
|
|
||||||
return matcher.matches();
|
return matcher.matches();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user