-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from team-JMT/feat/auto_login
자동 로그인 기능 구현
- Loading branch information
Showing
18 changed files
with
194 additions
and
48 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
data/src/main/java/org/gdsc/data/datasource/TokenDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.gdsc.data.datasource | ||
|
||
import org.gdsc.data.model.Response | ||
import org.gdsc.domain.model.response.TokenResponse | ||
|
||
interface TokenDataSource { | ||
|
||
suspend fun postRefreshToken(refreshToken: String): Response<TokenResponse> | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/org/gdsc/data/datasource/TokenDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.gdsc.data.datasource | ||
|
||
import org.gdsc.data.model.Response | ||
import org.gdsc.data.network.TokenAPI | ||
import org.gdsc.domain.model.request.RefreshTokenRequest | ||
import org.gdsc.domain.model.response.TokenResponse | ||
import javax.inject.Inject | ||
|
||
class TokenDataSourceImpl @Inject constructor( | ||
private val tokenAPI: TokenAPI | ||
): TokenDataSource { | ||
override suspend fun postRefreshToken(refreshToken: String): Response<TokenResponse> { | ||
return tokenAPI.refreshToken(RefreshTokenRequest(refreshToken)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.gdsc.data.network | ||
|
||
import org.gdsc.data.model.Response | ||
import org.gdsc.domain.model.request.RefreshTokenRequest | ||
import org.gdsc.domain.model.response.TokenResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface TokenAPI { | ||
@POST("api/v1/token") | ||
suspend fun refreshToken( | ||
@Body request: RefreshTokenRequest | ||
): Response<TokenResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/org/gdsc/domain/model/request/RefreshTokenRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.gdsc.domain.model.request | ||
|
||
data class RefreshTokenRequest( | ||
val refreshToken: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/ClearTokenInfoUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class ClearTokenInfoUseCase @Inject constructor( | ||
private val tokenManager: TokenManager | ||
private val tokenRepository: TokenRepository | ||
) { | ||
suspend operator fun invoke() { | ||
tokenManager.clearTokenInfo() | ||
tokenRepository.clearTokenInfo() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/GetAccessTokenExpiresInUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class GetAccessTokenExpiresInUseCase @Inject constructor( | ||
private val tokenManager: TokenManager | ||
private val tokenRepository: TokenRepository | ||
) { | ||
|
||
suspend operator fun invoke(): Long { | ||
return tokenManager.getAccessTokenExpiresIn() | ||
return tokenRepository.getAccessTokenExpiresIn() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/GetAccessTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class GetAccessTokenUseCase @Inject constructor( | ||
private val tokenManager: TokenManager | ||
private val tokenRepository: TokenRepository | ||
) { | ||
|
||
suspend operator fun invoke(): String { | ||
return tokenManager.getAccessToken() | ||
return tokenRepository.getAccessToken() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/GetGrantTypeUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class GetGrantTypeUseCase @Inject constructor( | ||
private val tokenManager: TokenManager | ||
private val tokenRepository: TokenRepository | ||
) { | ||
|
||
suspend operator fun invoke(): String { | ||
return tokenManager.getGrantType() | ||
return tokenRepository.getGrantType() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/GetRefreshTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class GetRefreshTokenUseCase @Inject constructor( | ||
private val tokenManager: TokenManager | ||
private val tokenRepository: TokenRepository | ||
) { | ||
|
||
suspend operator fun invoke(): String { | ||
return tokenManager.getRefreshToken() | ||
return tokenRepository.getRefreshToken() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
domain/src/main/java/org/gdsc/domain/usecase/token/PostRefreshTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class PostRefreshTokenUseCase@Inject constructor( | ||
private val tokenRepository: TokenRepository | ||
) { | ||
|
||
suspend operator fun invoke(refreshToken: String): Boolean { | ||
return tokenRepository.requestRefreshToken(refreshToken) | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
domain/src/main/java/org/gdsc/domain/usecase/token/SaveTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package org.gdsc.domain.usecase.token | ||
|
||
import org.gdsc.domain.model.response.TokenResponse | ||
import org.gdsc.domain.repository.TokenManager | ||
import org.gdsc.domain.repository.TokenRepository | ||
import javax.inject.Inject | ||
|
||
class SaveTokenUseCase @Inject constructor( | ||
private val tokenManager: TokenManager, | ||
private val tokenRepository: TokenRepository, | ||
){ | ||
|
||
suspend operator fun invoke( | ||
response: TokenResponse | ||
) { | ||
tokenManager.saveTokenInfo(response) | ||
tokenRepository.saveTokenInfo(response) | ||
|
||
} | ||
} |
Oops, something went wrong.