Skip to content

Commit

Permalink
Tht server 255 [App] 자기소개 버그 수정 및 userToken 중복생성 오류 수정 (#256)
Browse files Browse the repository at this point in the history
* fix : 자기소개 업데이트시 필드값을 인식못하는 문제 수정

* fix : sns 통합회원가입시 유저 토큰 중복 생성되는 오류 수정
  • Loading branch information
thalals authored Aug 3, 2024
1 parent 420c5b1 commit 71c4bfc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public TokenDto signUp(final UserSignUpRequest request) {

private TokenDto getUserSignUpResponse(User user) {
final TokenDto tokenDto = tokenProvider.generateJWT(user);
userTokenService.create(user.getUserUuid(), tokenDto.accessToken());

userTokenService.generateUserToken(user.getUserUuid(), tokenDto.accessToken());

return tokenDto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public TokenDto login(final UserLoginRequest request) {
private TokenDto getGenerateJWT(final User user) {

final TokenDto tokenDto = tokenProvider.generateJWT(user);
userTokenService.findByUserUuid(user.getUserUuid()).refresh(tokenDto.accessToken());
userTokenService.refresh(user.getUserUuid(), tokenDto.accessToken());

return tokenDto;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.tht.thtapis.facade.user.request;

public record ModifiedIntroductionRequest(
String introduction
) {
}
4 changes: 2 additions & 2 deletions tht-apis/src/main/java/com/tht/thtapis/ui/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ public ResponseEntity<TokenDto> updateNickName(
@PatchMapping("/user/introduction")
public ResponseEntity<Object> updateSelfIntroduce(
@AuthenticationPrincipal final User user,
@RequestBody final String introduction) {
@RequestBody final ModifiedIntroductionRequest request) {

userFacade.updateIntroduction(user, introduction);
userFacade.updateIntroduction(user, request.introduction());
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service
@Transactional
@RequiredArgsConstructor
Expand All @@ -27,7 +29,23 @@ public UserToken findByUserUuid(final String userUuid) {
}


public void create(final String userUuid, final String accessToken) {

public void refresh(final String userUuid, final String accessToken) {
UserToken userToken = findByUserUuid(userUuid);
userToken.refresh(accessToken);
}

public void generateUserToken(final String userUuid, final String accessToken) {
final Optional<UserToken> userToken = userTokenRepository.findByUserUuid(userUuid);

if(userToken.isPresent()) {
userToken.get().refresh(accessToken);
return;
}
create(userUuid, accessToken);
}

private void create(final String userUuid, final String accessToken) {
userTokenRepository.save(UserToken.create(userUuid, accessToken));
}
}

0 comments on commit 71c4bfc

Please sign in to comment.