Skip to content

Commit

Permalink
Merge pull request #66 from AR-TTUBEOG/fix/63
Browse files Browse the repository at this point in the history
[Fix] 닉네임 설정 500에러 수정
  • Loading branch information
arinming authored Feb 17, 2024
2 parents 6066093 + 50994fb commit 82b3e0d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
19 changes: 14 additions & 5 deletions src/main/java/com/ttubeog/domain/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,24 @@ private OAuthTokenResponse generateOAuthTokenResponse(Platform platform, String
.map(existingMember -> {
validateStatus(existingMember);
String accessToken = issueAccessToken(existingMember);
String refreshToken = issueRefreshToken();
String refreshToken = issueRefreshToken(existingMember);
refreshTokenService.saveTokenInfo(existingMember.getId(), refreshToken, accessToken);
return new OAuthTokenResponse(accessToken, refreshToken, true);
if(existingMember.getNickname() == null) {
Member newMember = new Member(email, platform, Status.ACTIVE, platformId, false);
Member savedMember = memberRepository.save(newMember);
accessToken = issueAccessToken(savedMember);
refreshToken = issueRefreshToken(savedMember);
refreshTokenService.saveTokenInfo(savedMember.getId(), refreshToken, accessToken);
return new OAuthTokenResponse(accessToken, refreshToken, false);
} else {
return new OAuthTokenResponse(accessToken, refreshToken, true);
}
})
.orElseGet(() -> {
Member newMember = new Member(email, platform, Status.ACTIVE, platformId, false);
Member savedMember = memberRepository.save(newMember);
String accessToken = issueAccessToken(savedMember);
String refreshToken = issueRefreshToken();
String refreshToken = issueRefreshToken(savedMember);
refreshTokenService.saveTokenInfo(savedMember.getId(), refreshToken, accessToken);
return new OAuthTokenResponse(accessToken, refreshToken, false);
});
Expand All @@ -115,8 +124,8 @@ private String issueAccessToken(final Member findMember) {
return jwtTokenProvider.createAccessToken(findMember.getId());
}

private String issueRefreshToken() {
return Token.createRefreshToken();
private String issueRefreshToken(final Member findMember) {
return jwtTokenProvider.createRefreshToken(findMember.getId());
}

private void validateStatus(final Member member) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ResponseEntity<?> postMemberNickname(HttpServletRequest request, ProduceN
MemberNicknameRes memberNicknameRes = MemberNicknameRes.builder()
.id(checkMember.getId())
.nickname(checkMember.getNickname())
.isChanged(checkMember.getNicknameChange())
.nicknameChanged(checkMember.getNicknameChange())
.build();

ApiResponse apiResponse = ApiResponse.builder()
Expand All @@ -90,8 +90,6 @@ public ResponseEntity<?> postMemberNickname(HttpServletRequest request, ProduceN

// 닉네임 업데이트
memberRepository.updateMemberNickname(produceNicknameRequest.getNickname(), memberId);

// 닉네임 1회 변경 true로 변경
memberRepository.updateMemberNicknameChange(true, memberId);

Optional<Member> checkMember = memberRepository.findById(memberId);
Expand All @@ -100,7 +98,7 @@ public ResponseEntity<?> postMemberNickname(HttpServletRequest request, ProduceN
MemberNicknameRes memberNicknameRes = MemberNicknameRes.builder()
.id(member.getId())
.nickname(produceNicknameRequest.getNickname())
.isChanged(member.getNicknameChange())
.nicknameChanged(member.getNicknameChange())
.build();

ApiResponse apiResponse = ApiResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class MemberNicknameRes {
private Long id;
private String nickname;

private Boolean isChanged;
private Boolean nicknameChanged;

public static MemberNicknameRes toDto(Member member) {
return MemberNicknameRes.builder()
.id(member.getId())
.nickname(member.getNickname())
.isChanged(member.getNicknameChange())
.nicknameChanged(member.getNicknameChange())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public ResponseEntity<?> deleteStore(HttpServletRequest request, Long storeId) {

storeRepository.delete(store);


ApiResponse apiResponse = ApiResponse.builder()
.check(true)
.information(Message.builder().message("매장 정보가 정상적으로 삭제되었습니다.").build())
Expand Down

0 comments on commit 82b3e0d

Please sign in to comment.