Skip to content

Commit

Permalink
Merge branch 'feature/DRAW-177' into sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
comforest committed Jul 30, 2024
2 parents db1ab99 + 8838704 commit 531ab02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package com.xorker.draw.auth.token
import com.xorker.draw.support.jwt.JwtProvider
import com.xorker.draw.support.jwt.JwtSecretKey
import com.xorker.draw.user.UserId
import java.time.Duration
import java.time.LocalDateTime
import java.time.temporal.TemporalAmount
import org.springframework.stereotype.Component

@Component
internal class AccessTokenAdapter(
private val jwtProvider: JwtProvider,
private val jwtSecretKey: JwtSecretKey,
) : AccessTokenRepository {
override fun createAccessToken(userId: UserId, expiredTime: Duration): String {
override fun createAccessToken(userId: UserId, expiredTime: TemporalAmount): String {
val now = LocalDateTime.now()
return jwtProvider.generate(
id = userId.value.toString(),
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/kotlin/com/xorker/draw/auth/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import com.xorker.draw.user.User
import com.xorker.draw.user.UserId
import com.xorker.draw.user.UserRepository
import java.time.Duration
import java.time.temporal.ChronoUnit
import java.time.Period
import java.time.temporal.TemporalAmount
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand All @@ -29,7 +30,7 @@ internal class AuthService(
override fun anonymousSignIn(): Token {
val user = userRepository.createUser(""); // TODO 이름 정책 정해지면 변경 예정

return createToken(user.id, Duration.of(100, ChronoUnit.YEARS))
return createToken(user.id, Period.ofYears(100))
}

override fun reissue(refreshToken: String): Token {
Expand All @@ -50,7 +51,7 @@ internal class AuthService(
return userRepository.createUser(authType.authPlatform, platformUserId, userName)
}

private fun createToken(userId: UserId, expiredTime: Duration): Token {
private fun createToken(userId: UserId, expiredTime: TemporalAmount): Token {
return Token(
accessToken = accessTokenRepository.createAccessToken(userId, expiredTime),
refreshToken = refreshTokenRepository.createRefreshToken(userId),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.xorker.draw.auth.token

import com.xorker.draw.user.UserId
import java.time.Duration
import java.time.temporal.TemporalAmount

interface AccessTokenRepository {
fun createAccessToken(userId: UserId, expiredTime: Duration): String
fun createAccessToken(userId: UserId, expiredTime: TemporalAmount): String
}

0 comments on commit 531ab02

Please sign in to comment.