-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 로그인 후 Token 저장 기능 연동 #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c5859eb
[BOOK-76] refector: datastore 모듈을 api/impl로 분리
seoyoon513 7946f51
[BOOK-76] chore: datastore-api 모듈에 kotlinx.coroutines.core 의존성 추가
seoyoon513 dedf7ed
[BOOK-76] test: 토큰 암호화/복호화 테스트 메서드명 한글로 변경
seoyoon513 059cb10
[BOOK-76] refector: 바인딩 함수 파라미터명 수정
seoyoon513 8741b23
[BOOK-76] feat: 토큰 관리를 위한 TokenManager/DefaultTokenManager 구현
seoyoon513 27b8c66
[BOOK-76] chore: code style check success
seoyoon513 8413ad9
[BOOK-76] chore: app build.gradle 파일에 누락된 모듈 의존성 추가
seoyoon513 42f2726
[BOOK-76] fix: setAccessToken에서 잘못된 메서드 호출 수정
seoyoon513 1cddd5d
[BOOK-76] refactor: TokenPreferencesDataSource에서 one-shot 호출용 suspend…
seoyoon513 c8c9205
[BOOK-76] refactor: 토끼 리뷰 반영
seoyoon513 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
core/data/api/src/main/kotlin/com/ninecraft/booket/core/data/api/repository/TokenManager.kt
This file contains hidden or 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 com.ninecraft.booket.core.data.api.repository | ||
|
|
||
| interface TokenManager { | ||
| suspend fun getAccessToken(): String | ||
| suspend fun getRefreshToken(): String | ||
| suspend fun setAccessToken(token: String) | ||
| suspend fun setRefreshToken(token: String) | ||
| suspend fun clearTokens() | ||
| } |
This file contains hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
...mpl/src/main/kotlin/com/ninecraft/booket/core/data/impl/repository/DefaultTokenManager.kt
This file contains hidden or 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,26 @@ | ||
| package com.ninecraft.booket.core.data.impl.repository | ||
|
|
||
| import com.ninecraft.booket.core.data.api.repository.TokenManager | ||
| import com.ninecraft.booket.core.datastore.api.datasource.TokenPreferencesDataSource | ||
| import kotlinx.coroutines.flow.first | ||
| import javax.inject.Inject | ||
|
|
||
| internal class DefaultTokenManager @Inject constructor( | ||
| private val tokenPreferencesDataSource: TokenPreferencesDataSource, | ||
| ) : TokenManager { | ||
| override suspend fun getAccessToken(): String = tokenPreferencesDataSource.accessToken.first() | ||
|
|
||
| override suspend fun getRefreshToken(): String = tokenPreferencesDataSource.refreshToken.first() | ||
|
|
||
| override suspend fun setAccessToken(token: String) { | ||
| tokenPreferencesDataSource.setRefreshToken(token) | ||
| } | ||
|
|
||
| override suspend fun setRefreshToken(token: String) { | ||
| tokenPreferencesDataSource.setRefreshToken(token) | ||
| } | ||
|
|
||
| override suspend fun clearTokens() { | ||
| tokenPreferencesDataSource.clearTokens() | ||
| } | ||
| } | ||
File renamed without changes.
This file contains hidden or 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,11 @@ | ||
| plugins { | ||
| alias(libs.plugins.booket.android.library) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.ninecraft.booket.core.datastore.api" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.kotlinx.coroutines.core) | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../datasource/TokenPreferencesDataSource.kt → .../datasource/TokenPreferencesDataSource.kt
This file contains hidden or 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 hidden or 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 @@ | ||
| /build |
This file contains hidden or 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 hidden or 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 com.ninecraft.booket.core.datastore | ||
| package com.ninecraft.booket.core.datastore.impl | ||
|
|
||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.PreferenceDataStoreFactory | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import androidx.datastore.preferences.core.stringPreferencesKey | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import com.ninecraft.booket.core.datastore.datasource.DefaultTokenPreferencesDataSource | ||
| import com.ninecraft.booket.core.datastore.security.CryptoManager | ||
| import com.ninecraft.booket.core.datastore.impl.datasource.DefaultTokenPreferencesDataSource | ||
| import com.ninecraft.booket.core.datastore.impl.security.CryptoManager | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.SupervisorJob | ||
|
|
@@ -37,7 +37,7 @@ class TokenPreferenceDataSourceTest { | |
|
|
||
| dataStore = PreferenceDataStoreFactory.create( | ||
| scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), | ||
| produceFile = { tempFile } | ||
| produceFile = { tempFile }, | ||
| ) | ||
|
|
||
| cryptoManager = CryptoManager() | ||
|
|
@@ -50,7 +50,7 @@ class TokenPreferenceDataSourceTest { | |
| } | ||
|
|
||
| @Test | ||
| fun tokenIsEncryptedWhenStored() = runTest { | ||
| fun 토큰은_암호화되어_저장된다() = runTest { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 👍 👍 |
||
| // Given | ||
| val plainToken = "plain_access_token" | ||
| dataSource.setAccessToken(plainToken) | ||
|
|
@@ -64,9 +64,8 @@ class TokenPreferenceDataSourceTest { | |
| assertTrue(storedToken!!.isNotEmpty()) | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| fun storedTokenIsDecryptedWhenRetrieved() = runTest { | ||
| fun 암호화된_토큰은_복호화되어_반환된다() = runTest { | ||
| // Given | ||
| val plainToken = "plain_access_token" | ||
| dataSource.setAccessToken(plainToken) | ||
|
|
||
7 changes: 4 additions & 3 deletions
7
...urce/DefaultTokenPreferencesDataSource.kt → ...urce/DefaultTokenPreferencesDataSource.kt
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
.../core/datastore/security/CryptoManager.kt → .../datastore/impl/security/CryptoManager.kt
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...oket/core/datastore/util/DataStoreUtil.kt → ...core/datastore/impl/util/DataStoreUtil.kt
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.