관리자 관리수정, 에러코드 공통 추가
This commit is contained in:
@@ -7,6 +7,7 @@ import com.kamco.cd.kamcoback.members.dto.SignInRequest;
|
||||
import com.kamco.cd.kamcoback.members.service.AuthService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
@@ -14,7 +15,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -55,12 +55,43 @@ public class AuthController {
|
||||
content = @Content(schema = @Schema(implementation = TokenResponse.class))),
|
||||
@ApiResponse(
|
||||
responseCode = "401",
|
||||
description = "ID 또는 비밀번호 불일치",
|
||||
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
|
||||
@ApiResponse(
|
||||
responseCode = "400",
|
||||
description = "미사용 상태",
|
||||
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
|
||||
description = "로그인 실패 (아이디/비밀번호 오류, 계정잠금 등)",
|
||||
content =
|
||||
@Content(
|
||||
schema = @Schema(implementation = ErrorResponse.class),
|
||||
examples = {
|
||||
@ExampleObject(
|
||||
name = "아이디 입력 오류",
|
||||
description = "존재하지 않는 아이디",
|
||||
value = """
|
||||
{
|
||||
"code": "LOGIN_ID_NOT_FOUND",
|
||||
"message": "아이디를 잘못 입력하셨습니다.",
|
||||
"detail": null
|
||||
}
|
||||
"""),
|
||||
@ExampleObject(
|
||||
name = "비밀번호 입력 오류 (4회 이하)",
|
||||
description = "아이디는 정상, 비밀번호를 여러 번 틀린 경우",
|
||||
value = """
|
||||
{
|
||||
"code": "LOGIN_PASSWORD_MISMATCH",
|
||||
"message": "비밀번호를 잘못 입력하셨습니다.",
|
||||
"detail": "비밀번호 입력 오류 3회, 2회 남았습니다."
|
||||
}
|
||||
"""),
|
||||
@ExampleObject(
|
||||
name = "비밀번호 오류 횟수 초과",
|
||||
description = "비밀번호 5회 이상 오류로 계정 잠김",
|
||||
value = """
|
||||
{
|
||||
"code": "LOGIN_PASSWORD_EXCEEDED",
|
||||
"message": "비밀번호 오류 횟수를 초과하여 이용하실 수 없습니다.",
|
||||
"detail": "로그인 오류에 대해 관리자에게 문의하시기 바랍니다."
|
||||
}
|
||||
""")
|
||||
}
|
||||
))
|
||||
})
|
||||
public ApiResponseDto<TokenResponse> signin(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
@@ -75,15 +106,14 @@ public class AuthController {
|
||||
new UsernamePasswordAuthenticationToken(request.getUsername(), request.getPassword()));
|
||||
|
||||
String status = authService.getUserStatus(request);
|
||||
if ("INACTIVE".equals(status)) {
|
||||
|
||||
// INACTIVE 비활성 상태(새로운 패스워드 입력 해야함), ARCHIVED 탈퇴
|
||||
if (!"ACTIVE".equals(status)) {
|
||||
return ApiResponseDto.ok(new TokenResponse(status, null, null));
|
||||
}
|
||||
|
||||
String username = authentication.getName(); // UserDetailsService 에서 사용한 username
|
||||
|
||||
// 로그인 시간 저장
|
||||
authService.saveLogin(UUID.fromString(username));
|
||||
|
||||
String accessToken = jwtTokenProvider.createAccessToken(username);
|
||||
String refreshToken = jwtTokenProvider.createRefreshToken(username);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user