diff --git a/src/main/java/com/bside/BSIDE/contents/web/AnswerController.java b/src/main/java/com/bside/BSIDE/contents/web/AnswerController.java index 2c5b275..bfcd631 100644 --- a/src/main/java/com/bside/BSIDE/contents/web/AnswerController.java +++ b/src/main/java/com/bside/BSIDE/contents/web/AnswerController.java @@ -86,9 +86,9 @@ public ResponseEntity passAnswer(@RequestBody Map obj) { answerService.passAnswer(qNo, email); return ResponseEntity.ok(msg); } - - /* 답변하지 않은 질문 삭제 */ + @Scheduled(cron = "0 0 0 * * *") + /* 답변하지 않은 질문 삭제 */ public ResponseEntity deleteUnanswer() { answerService.deleteUnanswer(); String msg = "Unanswer delete successful."; diff --git a/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java b/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java index 66ae158..f89fb76 100644 --- a/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java +++ b/src/main/java/com/bside/BSIDE/user/service/EmailServiceImpl.java @@ -108,7 +108,7 @@ public String sendCodeMessage(String to) throws Exception { public String sendTemporaryPassword(String to, String temporaryPassword) throws Exception { MimeMessage message = emailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true, "utf-8"); - + helper.setTo(to); // 수신자 이메일 주소 helper.setSubject("Goming 비밀번호 찾기"); // 제목 diff --git a/src/main/java/com/bside/BSIDE/user/web/PasswordResetController.java b/src/main/java/com/bside/BSIDE/user/web/PasswordResetController.java index 79450ba..e81a067 100644 --- a/src/main/java/com/bside/BSIDE/user/web/PasswordResetController.java +++ b/src/main/java/com/bside/BSIDE/user/web/PasswordResetController.java @@ -5,6 +5,9 @@ import java.security.NoSuchAlgorithmException; import java.util.Random; + +import com.bside.BSIDE.user.domain.EmailDto; +import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -23,7 +26,7 @@ * @일자 2023.05.12. **/ -@CrossOrigin +@CrossOrigin(origins = {"http://localhost:3000","http://www.goming.site"},allowCredentials = "true") @RestController @RequestMapping("/password") public class PasswordResetController { @@ -38,14 +41,16 @@ public PasswordResetController(UserService userService, EmailService emailServic @PostMapping("/password-reset") @Operation(summary = "임시 비밀번호 발급") - public String resetPassword(@RequestParam("email") String email) { + public String resetPassword(@RequestBody EmailDto param) { + System.out.println("@#테스트"); + System.out.println(param.getEmail()); // 1. 이메일 주소의 유효성 검사 - if (!isValidEmail(email)) { + if (!isValidEmail(param.getEmail())) { return "유효하지 않은 이메일 주소입니다."; } - + // 2. 이메일 주소의 존재 여부 확인 - UserDto user = userService.getUserByEmail(email); + UserDto user = userService.getUserByEmail(param.getEmail()); if (user == null) { return "해당 이메일로 가입된 사용자가 없습니다."; } @@ -53,13 +58,13 @@ public String resetPassword(@RequestParam("email") String email) { // 3. 임시 비밀번호 생성 및 이메일 전송 String temporaryPassword = generateTemporaryPassword(); try { - emailService.sendTemporaryPassword(email,temporaryPassword); + emailService.sendTemporaryPassword(param.getEmail(),temporaryPassword); } catch (Exception e) { return "이메일 전송에 실패했습니다."; } // 4. 임시 비밀번호 저장 - userService.saveTemporaryPassword(email, temporaryPassword); + userService.saveTemporaryPassword(param.getEmail(), temporaryPassword); return "임시 비밀번호가 이메일로 전송되었습니다."; }