Skip to content

Commit

Permalink
Merge pull request #84 from wooyeon0626/feature/join
Browse files Browse the repository at this point in the history
[CHORE] 이메일 인증 과정 중 해당 유저의 회원가입 과정 진행 상태에 따른 responseStatusName 수정 및 …
  • Loading branch information
easyoungcode authored Feb 10, 2024
2 parents 3a14c14 + 47152da commit 00667f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/wooyeon/yeon/user/domain/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Profile {
private boolean faceVerify;

@Builder
public Profile(char gender, String nickname, List<ProfilePhoto> profilePhotos, String birthday, String gpsLocationInfo, String mbti, String intro, String hobby, String interest, boolean faceVerify) {
public Profile(char gender, String nickname, List<ProfilePhoto> profilePhotos, String birthday, String gpsLocationInfo, String mbti, String intro, String hobby, String interest, boolean faceVerify, User user) {
this.gender = gender;
this.nickname = nickname;
this.profilePhotos = profilePhotos;
Expand All @@ -61,5 +61,6 @@ public Profile(char gender, String nickname, List<ProfilePhoto> profilePhotos, S
this.hobby = hobby;
this.interest = interest;
this.faceVerify = faceVerify;
this.user = user;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wooyeon.yeon.user.repository;

import com.wooyeon.yeon.user.domain.Profile;
import com.wooyeon.yeon.user.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -9,4 +10,6 @@
@Repository
public interface ProfileRepository extends JpaRepository<Profile, Long> {
Optional<Profile> findByNicknameContains(String searchWord);

Optional<Profile> findByUser(User user);
}
16 changes: 12 additions & 4 deletions src/main/java/com/wooyeon/yeon/user/service/EmailAuthService.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.wooyeon.yeon.user.service;

import com.wooyeon.yeon.user.domain.EmailAuth;
import com.wooyeon.yeon.user.domain.User;
import com.wooyeon.yeon.user.dto.emailAuth.EmailAuthResponseDto;
import com.wooyeon.yeon.user.dto.emailAuth.EmailRequestDto;
import com.wooyeon.yeon.user.dto.emailAuth.EmailResponseDto;
import com.wooyeon.yeon.user.repository.EmailAuthRepository;
import com.wooyeon.yeon.user.repository.ProfileRepository;
import com.wooyeon.yeon.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -36,6 +38,7 @@ public class EmailAuthService {
private final EmailAuthRepository emailAuthRepository;
private final JavaMailSender mailSender;
private final SpringTemplateEngine templateEngine;
private final ProfileRepository profileRepository;

// authToken 만료 시간 (10분)
private static final long EXPIRATION_TIME = 10 * 60 * 1000;
Expand Down Expand Up @@ -69,13 +72,18 @@ public EmailResponseDto sendEmail(EmailRequestDto emailRequestDto) throws Messag
Optional<EmailAuth> emailAuthOptional = emailAuthRepository.findEmailAuthByEmail(emailRequestDto.getEmail());
if (emailAuthOptional.isPresent() && emailAuthOptional.get().isCertification()) {
// 해당 이메일이 이미 인증된 경우
if (userRepository.findByEmail(emailRequestDto.getEmail()) != null) {
emailResponseDto.updateStatusName("ExistsUser");
User findUser = userRepository.findByEmail(emailRequestDto.getEmail());
if (findUser != null) {
if(profileRepository.findByUser(findUser).isPresent()) {
emailResponseDto.updateStatusName("ExistsProfile"); // 회원가입 완료 & 프로필 존재
} else {
emailResponseDto.updateStatusName("ExistsUser"); // 유저 존재 (회원가입 과정 완료)
}
} else {
emailResponseDto.updateStatusName("completed");
emailResponseDto.updateStatusName("completed"); // 이메일 인증 완료
}
} else {
emailResponseDto.updateStatusName("duplicated");
emailResponseDto.updateStatusName("duplicated"); // 이메일 인증이 완료된 상태 (그러나 회원가입 완료는 아님)
}
return emailResponseDto;
} else {
Expand Down

0 comments on commit 00667f5

Please sign in to comment.