Skip to content

Commit

Permalink
[FIX/#124] 토큰 재발급 기능 추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
chattymin committed Jan 15, 2024
1 parent ffaca75 commit ee3d292
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.going.data.dto.response.AuthResponseDto
interface TokenReissueDataSource {

suspend fun postReissueTokens(
authorization: String,
userId: TokenReissueRequestDto,
): BaseResponse<AuthResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import javax.inject.Inject
data class TokenReissueDataSourceImpl @Inject constructor(
private val tokenReissueService: TokenReissueService,
) : TokenReissueDataSource {
override suspend fun postReissueTokens(userId: TokenReissueRequestDto): BaseResponse<AuthResponseDto> =
tokenReissueService.postReissueTokens(userId)

override suspend fun postReissueTokens(
authorization: String,
userId: TokenReissueRequestDto,
): BaseResponse<AuthResponseDto> =
tokenReissueService.postReissueTokens(authorization, userId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ package com.going.data.repositoryImpl
import com.going.data.datasource.TokenReissueDataSource
import com.going.data.dto.request.toTokenReissueModel
import com.going.domain.entity.request.TokenReissueRequestModel
import com.going.domain.entity.response.TokenReissueModel
import com.going.domain.entity.response.AuthTokenModel
import com.going.domain.repository.TokenReissueRepository
import javax.inject.Inject

class TokenReissueRepositoryImpl @Inject constructor(
private val tokenReissueDataSource: TokenReissueDataSource,
) : TokenReissueRepository {
override suspend fun postReissueTokens(request: TokenReissueRequestModel): Result<TokenReissueModel> =

override suspend fun postReissueTokens(
authorization: String,
request: TokenReissueRequestModel,
): Result<AuthTokenModel> =
runCatching {
tokenReissueDataSource.postReissueTokens(request.toTokenReissueModel()).data.toTokenReissueModel()
tokenReissueDataSource.postReissueTokens(
authorization,
request.toTokenReissueModel(),
).data.toAuthTokenModel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import com.going.data.dto.BaseResponse
import com.going.data.dto.request.TokenReissueRequestDto
import com.going.data.dto.response.AuthResponseDto
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST

interface TokenReissueService {
@POST("api/users/reissue")
suspend fun postReissueTokens(
@Header("Authorization") authorization: String,
@Body request: TokenReissueRequestDto,
): BaseResponse<AuthResponseDto>
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.going.domain.repository

import com.going.domain.entity.request.TokenReissueRequestModel
import com.going.domain.entity.response.AuthTokenModel
import com.going.domain.entity.response.TokenReissueModel

interface TokenReissueRepository {
suspend fun postReissueTokens(
authorization: String,
request: TokenReissueRequestModel,
): Result<TokenReissueModel>
): Result<AuthTokenModel>
}

0 comments on commit ee3d292

Please sign in to comment.