Skip to content

Commit 9f0c443

Browse files
committed
fix: 이메일 인증 리디렉션 URL 통일
- 성공, 실패 시의 라우팅되는 URL을 통일함 - 하드코딩 된 URL이 아니라 properties에서 읽어오도록 함
1 parent 206fd47 commit 9f0c443

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/main/java/org/ezcode/codetest/presentation/usermanagement/UserVerifyController.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.ezcode.codetest.application.usermanagement.user.dto.response.VerifyFindPasswordResponse;
1111
import org.ezcode.codetest.domain.user.model.entity.AuthUser;
1212
import org.ezcode.codetest.domain.user.exception.UserException;
13+
import org.springframework.beans.factory.annotation.Value;
1314
import org.springframework.http.HttpStatus;
1415
import org.springframework.http.ResponseEntity;
1516
import org.springframework.security.core.annotation.AuthenticationPrincipal;
@@ -40,6 +41,9 @@
4041
public class UserVerifyController {
4142
private final AuthService authService;
4243

44+
@Value("${app.redirect.verify.url}")
45+
String verifyUrl;
46+
4347
@Operation(summary = "이메일 인증 코드 전송", description = "현재 로그인된 회원의 이메일로 인증 코드를 전송합니다.")
4448
@PostMapping("/email/send")
4549
public ResponseEntity<SendEmailResponse> sendMailCode(
@@ -59,25 +63,25 @@ public void verifyEmailCode(
5963
) throws IOException {
6064
try {
6165
authService.verifyEmailCode(email, key);
62-
66+
6367
// 성공 시 프론트엔드로 리디렉션
6468
String redirectUrl = UriComponentsBuilder
65-
.fromUriString("https://ezcode.my/email-verify-success")
69+
.fromUriString(verifyUrl)
6670
.queryParam("status", "success")
6771
.build()
6872
.toUriString();
69-
73+
7074
response.sendRedirect(redirectUrl);
7175
} catch (UserException e) {
7276
// 실패 시 프론트엔드로 리디렉션 (에러 메시지 포함)
7377
String errorMessage = URLEncoder.encode(e.getMessage(), StandardCharsets.UTF_8);
7478
String redirectUrl = UriComponentsBuilder
75-
.fromUriString("https://ezcode.my/email-verify-failure")
79+
.fromUriString(verifyUrl)
7680
.queryParam("status", "failure")
7781
.queryParam("message", errorMessage)
7882
.build()
7983
.toUriString();
80-
84+
8185
response.sendRedirect(redirectUrl);
8286
}
8387
}

src/main/resources/application.properties

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ resilience4j.circuitbreaker.instances.db-circuit.record-exceptions=org.springfra
165165

166166
# App Redirects (Email Verify)
167167
# ========================
168-
# 인증 성공 시 이동할 페이지 URL (예: 프론트의 성공 안내 페이지)
169-
app.redirect.verify.success=${APP_REDIRECT_VERIFY_SUCCESS:https://your-frontend.example.com/verify/success}
170-
# 인증 실패 시 이동할 페이지 URL (예: 프론트의 실패 안내 페이지)
171-
app.redirect.verify.failure=${APP_REDIRECT_VERIFY_FAILURE:https://your-frontend.example.com/verify/failure}
168+
app.redirect.verify.url=${APP_REDIRECT_VERIFY_SUCCESS:https://ezcode.my/email-verify}
172169

173170
# processor metrics (system.cpu, process.cpu)
174171
management.metrics.enable.process.cpu=false

0 commit comments

Comments
 (0)