-
Notifications
You must be signed in to change notification settings - Fork 1
[CHORE] 회원가입 로직 수정 #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[CHORE] 회원가입 로직 수정 #392
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e000994
feat:#391 signUp session repository 구축
gdbs1107 1a079c3
feat:#319 record 경로 수정
gdbs1107 f9715da
feat:#391 소셜로그인 로직 수정
gdbs1107 42bdb89
feat:#391 controller 명세 수정
gdbs1107 984488a
feat:#391 request DTO 생성
gdbs1107 edc8931
feat:#391 임시토큰을 이용한 회원 생성 로직 구현
gdbs1107 afef07c
chore:#391 테스트 코드 수정
gdbs1107 a9b089d
feat:#391 controller 테스트 코드 수정
gdbs1107 f9065e2
signup token repository map 수정
gdbs1107 9f18b39
chore:#391 크레딧 개수 5개로 조정
gdbs1107 bd5314f
chore:#391 테스트 빌드 수정
gdbs1107 1a23320
chore:#391 크레딧 개수 1개로 수정
gdbs1107 1bdc3f4
Merge branch 'develop' of https://github.com/TEAM-HOUME/HOUME-SERVER …
gdbs1107 cf5ebd2
chore:#391 테스트 코드 수정
gdbs1107 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
22 changes: 22 additions & 0 deletions
22
src/main/java/or/sopt/houme/domain/user/controller/dto/KakaoLoginResponse.java
This file contains hidden or 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,22 @@ | ||
| package or.sopt.houme.domain.user.controller.dto; | ||
|
|
||
| public record KakaoLoginResponse( | ||
| boolean isNewUser, | ||
| String signupToken, | ||
| Prefill prefill | ||
| ) { | ||
| public static KakaoLoginResponse newUser(String signupToken, String email, String nickname) { | ||
| return new KakaoLoginResponse(true, signupToken, new Prefill(email, nickname)); | ||
| } | ||
|
|
||
| public static KakaoLoginResponse existingUser() { | ||
| return new KakaoLoginResponse(false, null, null); | ||
| } | ||
|
|
||
| public record Prefill( | ||
| String email, | ||
| String nickname | ||
| ) { | ||
| } | ||
| } | ||
|
|
27 changes: 27 additions & 0 deletions
27
src/main/java/or/sopt/houme/domain/user/controller/dto/SocialSignUpRequest.java
This file contains hidden or 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,27 @@ | ||
| package or.sopt.houme.domain.user.controller.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import or.sopt.houme.domain.user.valid.ValidBirthday; | ||
|
|
||
| public record SocialSignUpRequest( | ||
| @NotBlank(message = "signupToken은 필수 입력값입니다.") | ||
| String signupToken, | ||
|
|
||
| @NotBlank(message = "이름은 필수 입력값입니다.") | ||
| @Pattern(regexp = "^[가-힣a-zA-Z]+$", message = "숫자, 특수문자는 입력할 수 없어요.") | ||
| String name, | ||
|
|
||
| @NotBlank(message = "성별은 필수 입력값입니다.") | ||
| @Pattern( | ||
| regexp = "MALE|FEMALE|NONBINARY", | ||
| message = "성별은 MALE, FEMALE, NONBINARY 중 하나여야 해요." | ||
| ) | ||
| String gender, | ||
|
|
||
| @NotBlank(message = "생년월일은 필수 입력값입니다.") | ||
| @ValidBirthday | ||
| String birthday | ||
| ) { | ||
| } | ||
|
|
12 changes: 12 additions & 0 deletions
12
src/main/java/or/sopt/houme/domain/user/entity/record/SignupSession.java
This file contains hidden or 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,12 @@ | ||
| package or.sopt.houme.domain.user.entity.record; | ||
|
|
||
| public record SignupSession( | ||
| Long kakaoId, | ||
| String email, | ||
| String nickname | ||
| ) { | ||
| public static SignupSession of(Long kakaoId, String email, String nickname) { | ||
| return new SignupSession(kakaoId, email, nickname); | ||
| } | ||
| } | ||
|
|
||
53 changes: 53 additions & 0 deletions
53
src/main/java/or/sopt/houme/domain/user/repository/SignupSessionRepository.java
This file contains hidden or 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,53 @@ | ||
| package or.sopt.houme.domain.user.repository; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import lombok.RequiredArgsConstructor; | ||
| import or.sopt.houme.domain.user.entity.record.SignupSession; | ||
| import org.springframework.data.redis.core.RedisTemplate; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class SignupSessionRepository { | ||
|
|
||
| private final RedisTemplate<String, Object> redisTemplate; | ||
| private final ObjectMapper objectMapper; | ||
|
|
||
| private static final String PREFIX = "signup-session:"; | ||
|
|
||
| public void save(String signupToken, SignupSession session, long ttlSeconds) { | ||
| if (!StringUtils.hasText(signupToken) || session == null) { | ||
| return; | ||
| } | ||
| String key = PREFIX + signupToken; | ||
| redisTemplate.opsForValue().set(key, session, Duration.ofSeconds(ttlSeconds)); | ||
| } | ||
gdbs1107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public Optional<SignupSession> consume(String signupToken) { | ||
| if (!StringUtils.hasText(signupToken)) { | ||
| return Optional.empty(); | ||
| } | ||
| String key = PREFIX + signupToken; | ||
|
|
||
| Object value; | ||
| try { | ||
| value = redisTemplate.opsForValue().getAndDelete(key); | ||
| } catch (Exception e) { | ||
| value = redisTemplate.opsForValue().get(key); | ||
| redisTemplate.delete(key); | ||
| } | ||
gdbs1107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (value instanceof SignupSession session) { | ||
| return Optional.of(session); | ||
| } | ||
| if (value instanceof Map<?, ?> map) { | ||
| return Optional.ofNullable(objectMapper.convertValue(map, SignupSession.class)); | ||
| } | ||
gdbs1107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return Optional.empty(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.