diff --git a/src/main/java/com/sch/chekirout/email/controller/EmailController.java b/src/main/java/com/sch/chekirout/email/controller/EmailController.java index 162103b..ad0f528 100644 --- a/src/main/java/com/sch/chekirout/email/controller/EmailController.java +++ b/src/main/java/com/sch/chekirout/email/controller/EmailController.java @@ -4,10 +4,16 @@ import com.sch.chekirout.email.service.EmailService; import com.sch.chekirout.user.application.UserService; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.IOException; +import java.net.URI; + @RestController @RequestMapping("/api/v1/auth") public class EmailController { @@ -31,9 +37,14 @@ public ResponseEntity verifyEmail(@RequestParam("token") String token) { boolean isVerified = emailService.verifyEmail(token); if (isVerified) { - return ResponseEntity.ok("이메일 인증이 완료되었습니다. 회원가입을 진행해주세요!!"); + // 인증 성공 시 리다이렉트 + HttpHeaders headers = new HttpHeaders(); + headers.setLocation(URI.create("https://dev.chekirout.com/email/verifyToken")); + return new ResponseEntity<>(headers, HttpStatus.FOUND); // 302 리다이렉트 } else { - return ResponseEntity.badRequest().body("유효하지 않거나 만료된 인증 토큰입니다."); + // 인증 실패 시 적절한 에러 메시지와 400 Bad Request 반환 + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body("유효하지 않거나 만료된 인증 토큰입니다."); } } diff --git a/src/main/java/com/sch/chekirout/email/service/EmailService.java b/src/main/java/com/sch/chekirout/email/service/EmailService.java index 84647b7..b3be03f 100644 --- a/src/main/java/com/sch/chekirout/email/service/EmailService.java +++ b/src/main/java/com/sch/chekirout/email/service/EmailService.java @@ -33,7 +33,7 @@ public void sendVerificationEmail(String recipientEmail) { String token = generateEmailVerificationToken(recipientEmail); String subject = "이메일 인증을 완료해주세요"; - String verificationUrl = "http://dev.chekirout.com/api/v1/auth/verify-email?token=" + token; + String verificationUrl = "https://dev.chekirout.com/api/v1/auth/verify-email?token=" + token; String message = "아래 링크를 클릭하여 이메일 인증을 완료하세요: 인증 링크"; try { @@ -44,7 +44,7 @@ public void sendVerificationEmail(String recipientEmail) { helper.setTo(recipientEmail); // 수신자 이메일 설정 helper.setSubject(subject); // 이메일 제목 설정 helper.setText(message, true); // HTML 형식으로 본문 설정 - helper.setFrom("chekirout "); + helper.setFrom("chekirout "); mailSender.send(email); // 이메일 전송 } catch (Exception e) { diff --git a/src/main/resources/application-db.yml b/src/main/resources/application-db.yml index f4a6cb9..c94b669 100644 --- a/src/main/resources/application-db.yml +++ b/src/main/resources/application-db.yml @@ -38,7 +38,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/chekirout username: root - password: rlawjdgns10! + password: root1234 p6spy: enabled: true appender: com.p6spy.engine.spy.appender.Slf4JLogger