Skip to content

Commit a3829db

Browse files
authored
Merge pull request #186 from GoTogether-Inc/fix/#185
2 parents 325d4b2 + c328dcd commit a3829db

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/main/java/com/gotogether/global/apipayload/code/status/ErrorStatus.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public enum ErrorStatus implements BaseErrorCode {
4848
_ORDER_ALREADY_CANCELED(HttpStatus.BAD_REQUEST, "ORDER4003", "이미 취소된 주문입니다."),
4949
_ORDER_ALREADY_COMPLETED(HttpStatus.BAD_REQUEST, "ORDER4004", "이미 승인된 주문입니다."),
5050

51-
_TOKEN_EXPIRED(HttpStatus.BAD_REQUEST, "TOKEN4001", "토큰이 만료되었습니다."),
51+
_TOKEN_EXPIRED(HttpStatus.BAD_REQUEST, "TOKEN4001", "로그인이 만료되었습니다."),
5252
_TOKEN_TYPE_ERROR(HttpStatus.BAD_REQUEST, "TOKEN4002", "토큰 타입이 잘못되었습니다."),
53-
_TOKEN_BLACKLISTED(HttpStatus.UNAUTHORIZED, "TOKEN4003", "로그아웃된 토큰입니다. 다시 로그인해주세요."),
54-
_TOKEN_NOT_EXISTS(HttpStatus.UNAUTHORIZED, "TOKEN4004", "토큰이 존재하지 않습니다. 로그인이 필요합니다."),
53+
_TOKEN_BLACKLISTED(HttpStatus.UNAUTHORIZED, "TOKEN4003", "로그아웃되었습니다. 다시 로그인해주세요."),
54+
_TOKEN_NOT_EXISTS(HttpStatus.UNAUTHORIZED, "TOKEN4004", "로그인이 필요합니다."),
5555

5656
_BOOKMARK_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "BOOKMARK4001", "이미 북마크된 이벤트입니다."),
5757
_BOOKMARK_NOT_FOUND(HttpStatus.NOT_FOUND, "BOOKMARK4002", "북마크를 찾을 수 없습니다."),

src/main/java/com/gotogether/global/oauth/handler/CustomFailureHandler.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@
22

33
import java.io.IOException;
44

5+
import org.springframework.beans.factory.annotation.Value;
56
import org.springframework.security.core.AuthenticationException;
67
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
78
import org.springframework.stereotype.Component;
89

9-
import com.gotogether.global.apipayload.code.status.ErrorStatus;
1010
import com.gotogether.global.oauth.exception.DuplicatedEmailException;
11-
import com.gotogether.global.oauth.util.ErrorResponseUtil;
1211

1312
import jakarta.servlet.http.HttpServletRequest;
1413
import jakarta.servlet.http.HttpServletResponse;
1514

1615
@Component
1716
public class CustomFailureHandler implements AuthenticationFailureHandler {
1817

18+
@Value("${app.redirect-url}")
19+
String redirectUrl;
20+
1921
@Override
2022
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
2123
AuthenticationException exception) throws IOException {
2224

25+
String status;
26+
2327
if (exception instanceof DuplicatedEmailException) {
24-
ErrorResponseUtil.sendErrorResponse(response, ErrorStatus._USER_EMAIL_ALREADY_EXISTS);
28+
status = "duplicatedEmail";
2529
} else {
26-
ErrorResponseUtil.sendErrorResponse(response, ErrorStatus._INTERNAL_SERVER_ERROR);
30+
status = "serverError";
2731
}
32+
33+
String targetUrl = redirectUrl + status;
34+
35+
response.sendRedirect(targetUrl);
2836
}
2937
}

0 commit comments

Comments
 (0)