Skip to content

Commit

Permalink
fix : 충돌 rebase 사용해서 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
YunJuwon0825 committed Feb 23, 2025
1 parent 352d851 commit a9667ee
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,11 @@ public CommonResponse<Void> reGenerateAccessToken(@CookieValue(value = "refreshT
return CommonResponse.of(SuccessCode.TOKEN_REISSUE_OK, null);
}


@Operation(summary = "모의 유저 데이터 생성")
@PostMapping("/mock/signup")
public CommonResponse<String> mockSignup(@RequestParam(name = "id") String id) {
String accessToken = userService.mockSignup(id);
return CommonResponse.of(SuccessCode.OK, accessToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,33 @@ public User getLoginUser() {
return userRepository.findByEmail(userDetails.getUsername())
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));
}

@Transactional
public JwtToken reissueAccessToken(String refreshToken) {

// Refresh Token 검증
if (!jwtService.isRefreshTokenValid(refreshToken)) {
return null;
}

User user = this.getLoginUser();
return JwtToken.builder()
.accessToken(jwtService.createAccessToken(user.getEmail()))
.refreshToken(refreshToken)
.build();
}

public String mockSignup(String id) {
String accessToken = jwtService.createAccessToken(id);
String refreshToken = jwtService.createRefreshToken();

User user = User.builder()
.refreshToken(refreshToken)
.email(id)
.username("mock")
.role(Role.REGULAR)
.socialType(SocialType.GOOGLE)
.build();
userRepository.save(user);

return accessToken;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.security.Key;
import java.time.Duration;
import java.util.Date;
import java.util.Optional;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.oauth2.jwt.JwtException;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -50,6 +52,7 @@ public class JwtService {

private final UserRepository userRepository;
private final RedisTemplate<String, String> redisTemplate;
private final RedisService redisService;

private Key key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.techeer.backend.api.user.service.UserService;
import com.techeer.backend.global.error.ErrorCode;
import com.techeer.backend.global.error.exception.BusinessException;
import com.techeer.backend.global.oauth.EmailFetcher.GitHubEmailFetcher;
import com.techeer.backend.global.oauth.OAuthAttributes;
import com.techeer.backend.global.oauth.oauth2user.CustomOAuth2User;
import java.util.Collections;
Expand Down

0 comments on commit a9667ee

Please sign in to comment.