Skip to content

Commit

Permalink
Merge pull request #175 from KUSITMS-29th-TEAM-B/fix/flight-172
Browse files Browse the repository at this point in the history
fix : 재로그인시 토큰 upsert 과정 수정
  • Loading branch information
isprogrammingfun authored Jun 4, 2024
2 parents ccacc98 + 93fb37c commit 5df55ea
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 43 deletions.
4 changes: 0 additions & 4 deletions Api-Module/src/main/resources/application-log.yml

This file was deleted.

1 change: 0 additions & 1 deletion Api-Module/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ spring:
include:
- db
- jwt
- log
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class TokenAppender (
) {
val existingToken = tokenRepository.findByUserId(userId)
existingToken?.let {
it.update(userId = userId, refreshToken = refreshToken)
tokenRepository.save(it)
val updatedToken = it.update(userId = userId, refreshToken = refreshToken)
tokenRepository.save(updatedToken)
} ?: Token.create(
userId = userId,
value = refreshToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TokenAppenderTest : BehaviorSpec({
Given("a user id and a refresh token, and the user has an existing token") {
val mockToken = mockk<Token>(relaxed = true)
every { mockTokenRepository.findByUserId(userId) } returns mockToken
every { mockToken.update(userId, refreshToken) } returns mockToken

When("appendToken is called") {
tokenAppender.appendToken(userId, refreshToken)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import java.util.*
@Component
class JwtProvider(
private val jwtProperties: JwtProperties,
private val jwtKeyGenerator: JwtKeyGenerator,
private val jwtRegistry: JwtRegistry
private val jwtKeyGenerator: JwtKeyGenerator
) {

fun generateAccessToken(user: Claims.UserClaims): String {
Expand All @@ -19,12 +18,10 @@ class JwtProvider(
}

fun generateRefreshToken(user: Claims.UserClaims): String {
val refreshToken = generateToken(
return generateToken(
user.createPrivateClaims(TokenType.REFRESH_TOKEN),
jwtProperties.refreshTokenExpirationTime
)
jwtRegistry.upsert(user.userId to refreshToken)
return refreshToken
}

fun generateRegistrationToken(registrationClaims: Claims.RegistrationClaims): String {
Expand Down

This file was deleted.

0 comments on commit 5df55ea

Please sign in to comment.