-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from ITA-OneByte/dev
[release] 프론트 요구사항
- Loading branch information
Showing
30 changed files
with
691 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
src/main/java/classfit/example/classfit/auth/dto/request/UserRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
package classfit.example.classfit.auth.dto.request; | ||
|
||
import jakarta.validation.ConstraintViolation; | ||
import jakarta.validation.Validation; | ||
import jakarta.validation.Validator; | ||
import jakarta.validation.ValidatorFactory; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public record UserRequest | ||
( | ||
@NotBlank(message = "이메일은 공백일 수 없습니다.") | ||
@Email(message = "형식이 올바르지 않습니다.") | ||
@Email(message = "이메일 형식이 올바르지 않습니다.") | ||
String email, | ||
|
||
@NotBlank(message = "비밀번호는 공백일 수 없습니다.") | ||
@Size(min = 8, max = 20, message = "비밀번호는 8 ~ 20자리로 입력해 주세요") | ||
String password | ||
) { | ||
|
||
public Optional<String> validate() { | ||
ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); | ||
Validator validator = factory.getValidator(); | ||
|
||
Set<ConstraintViolation<UserRequest>> violations = validator.validate(this); | ||
return violations.stream() | ||
.map(ConstraintViolation::getMessage) | ||
.findFirst(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/classfit/example/classfit/auth/exception/CustomAccessDeniedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package classfit.example.classfit.auth.exception; | ||
|
||
import classfit.example.classfit.common.ApiResponse; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.access.AccessDeniedException; | ||
import org.springframework.security.web.access.AccessDeniedHandler; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
|
||
@Component | ||
public class CustomAccessDeniedHandler implements AccessDeniedHandler { | ||
|
||
@Override | ||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException { | ||
ApiResponse.errorResponse(response, "접근 권한이 없습니다.", HttpStatus.UNAUTHORIZED.value()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/classfit/example/classfit/auth/exception/CustomAuthenticationEntryPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package classfit.example.classfit.auth.exception; | ||
|
||
import classfit.example.classfit.common.ApiResponse; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.web.AuthenticationEntryPoint; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
|
||
@Component | ||
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { | ||
|
||
@Override | ||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { | ||
ApiResponse.errorResponse(response, "접근 권한이 없습니다.", HttpStatus.UNAUTHORIZED.value()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
...ava/classfit/example/classfit/auth/security/exception/CustomAuthenticationEntryPoint.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.