-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from bandalgomsu/develop
Develop
- Loading branch information
Showing
10 changed files
with
151 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/com/example/jolvre/auth/email/service/MailVerifyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.example.jolvre.auth.email.service; | ||
|
||
import com.example.jolvre.auth.dto.SignUpDTO.TokenResponse; | ||
import com.example.jolvre.auth.email.dto.EmailDTO.FindPwEmailVerifyResponse; | ||
import com.example.jolvre.auth.email.dto.EmailDTO.SignUpEmailVerifyResponse; | ||
import com.example.jolvre.auth.jwt.service.JwtService; | ||
import com.example.jolvre.common.error.user.UserNotFoundException; | ||
import com.example.jolvre.common.util.RedisUtil; | ||
import com.example.jolvre.user.entity.User; | ||
import com.example.jolvre.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class MailVerifyService { | ||
private final RedisUtil redisUtil; | ||
private final JwtService jwtService; | ||
private final UserRepository userRepository; | ||
|
||
public SignUpEmailVerifyResponse CheckSignUpAuthNum(String email, String authNum) { | ||
if (redisUtil.getData(email) == null) { | ||
return SignUpEmailVerifyResponse.builder() | ||
.verifyResult(false) | ||
.email(email) | ||
.build(); | ||
|
||
} else if (redisUtil.getData(email).equals(authNum)) { | ||
redisUtil.deleteData(email); | ||
return SignUpEmailVerifyResponse.builder() | ||
.verifyResult(true) | ||
.email(email) | ||
.build(); | ||
} | ||
|
||
return SignUpEmailVerifyResponse.builder() | ||
.verifyResult(false) | ||
.email(email) | ||
.build(); | ||
} | ||
|
||
public FindPwEmailVerifyResponse CheckFindPwAuthNum(String email, String authNum) { | ||
User targetUser = userRepository.findByEmail(email).orElseThrow(UserNotFoundException::new); | ||
|
||
if (redisUtil.getData(email) == null) { | ||
return FindPwEmailVerifyResponse.builder() | ||
.verifyResult(false) | ||
.email(email) | ||
.build(); | ||
} else if (redisUtil.getData(email).equals(authNum)) { | ||
redisUtil.deleteData(email); | ||
|
||
TokenResponse token = TokenResponse.builder() | ||
.accessToken(jwtService.createAccessToken(targetUser.getEmail())) | ||
.refreshToken(jwtService.reIssueRefreshToken(targetUser)) | ||
.build(); | ||
|
||
return FindPwEmailVerifyResponse.builder() | ||
.verifyResult(true) | ||
.email(email) | ||
.tokenResponse(token) | ||
.build(); | ||
} | ||
|
||
return FindPwEmailVerifyResponse.builder() | ||
.verifyResult(false) | ||
.email(email) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 14 additions & 3 deletions
17
src/main/java/com/example/jolvre/common/firebase/Entity/UserFcmToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.