Skip to content

Commit

Permalink
Merge pull request #69 from TRIP-Side-Project/dev
Browse files Browse the repository at this point in the history
회원 가입 로직 버그 수정
  • Loading branch information
don9m1n authored Dec 15, 2023
2 parents 1d4cbb0 + 8b79d13 commit a4b2b2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface EmailAuthRepository extends JpaRepository<EmailAuth, Long>, EmailAuthRepositoryCustom {

Optional<EmailAuth> findByEmail(String email);
Optional<EmailAuth> findTop1ByEmailAndExpiredIsTrueOrderByCreatedAtDesc(String email);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.api.trip.domain.member.controller.dto.EmailResponse;
import com.api.trip.domain.member.controller.dto.FindPasswordRequest;
import com.api.trip.domain.member.model.Member;
import com.api.trip.domain.member.repository.MemberRepository;
import com.api.trip.domain.member.service.MemberService;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
Expand All @@ -29,10 +30,15 @@ public class EmailService {
private final MemberService memberService;
private final JavaMailSender javaMailSender;
private final EmailAuthRepository emailAuthRepository;
private final MemberRepository memberRepository;

@Async
public void send(String email, String authToken) {

if (memberRepository.findByEmail(email).isPresent()) {
throw new RuntimeException("이메일 인증이 완료된 회원입니다!");
}

String authLink = "https://triptrip.site/api/members/auth-email/%s/%s".formatted(email, authToken);

MimeMessage message = javaMailSender.createMimeMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void join(JoinRequest joinRequest, MultipartFile profileImg) throws IOExc
});

// 이메일 인증이 완료 여부 검사
EmailAuth emailAuth = emailAuthRepository.findByEmail(joinRequest.getEmail())
EmailAuth emailAuth = emailAuthRepository.findTop1ByEmailAndExpiredIsTrueOrderByCreatedAtDesc(joinRequest.getEmail())
.orElseThrow(() -> new RuntimeException("이메일 인증 토큰 정보가 없습니다!"));

String profileImgUrl = "";
Expand Down

0 comments on commit a4b2b2c

Please sign in to comment.