-
Notifications
You must be signed in to change notification settings - Fork 0
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
로그인 상태라면 인증 헤더 넣기 #152
Merged
Merged
로그인 상태라면 인증 헤더 넣기 #152
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2410374
refactor : authRepositoryImpl과 data store 사이에 dataSource 놓기
HamBP 1a84976
feat : auth interceptor 추가
HamBP 11d3faa
feat : 로그인을 시도하면 메모리에 token 저장
HamBP 70dfa34
feat : 회원가입을 완료하면 홈 화면으로 이동
HamBP f4f4cf4
fix : 리팩터링 과정에서 생긴 무한 스플래시 버그 수정
HamBP 876b0c4
fix : token에 bearer 추가
HamBP a4da1fa
feat : 유효 token 검사 로직 추가
HamBP 1909be7
refactor : token data source 다시 제거
HamBP 3b336d8
refactor : interceptor 파일 이름 변경
HamBP 8bb7c82
fix : token data source를 이용해 토큰 저장 및 불러오기
HamBP 7586850
refactor : 토큰 스토어 삭제
HamBP 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 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
23 changes: 23 additions & 0 deletions
23
...re/data/src/main/java/com/ohdodok/catchytape/core/data/datasource/TokenLocalDataSource.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,23 @@ | ||
package com.ohdodok.catchytape.core.data.datasource | ||
|
||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.edit | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class TokenLocalDataSource @Inject constructor( | ||
private val dataStore: DataStore<Preferences> | ||
) { | ||
|
||
private val accessTokenKey = stringPreferencesKey("accessToken") | ||
|
||
suspend fun getAccessToken(): String = | ||
dataStore.data.map { preferences -> preferences[accessTokenKey] ?: "" }.first() | ||
|
||
suspend fun saveAccessToken(token: String) { | ||
dataStore.edit { preferences -> preferences[accessTokenKey] = token } | ||
} | ||
} |
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: 6 additions & 0 deletions
6
.../core/data/src/main/java/com/ohdodok/catchytape/core/data/di/qualifier/AuthInterceptor.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,6 @@ | ||
package com.ohdodok.catchytape.core.data.di.qualifier | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
annotation class AuthInterceptor |
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
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,5 +1,7 @@ | ||
package com.ohdodok.catchytape.feature.login | ||
|
||
import android.content.ComponentName | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.TextView | ||
|
@@ -41,6 +43,9 @@ class NicknameFragment : BaseFragment<FragmentNicknameBinding>(R.layout.fragment | |
viewModel.events.collect { event -> | ||
when (event) { | ||
is NicknameEvent.NavigateToHome -> { | ||
val intent = Intent() | ||
intent.component = ComponentName("com.ohdodok.catchytape", "com.ohdodok.catchytape.MainActivity") | ||
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. 이것도 임시 코드 |
||
startActivity(intent) | ||
activity?.finish() | ||
} | ||
} | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
토큰 가져오기보다는 자동으로 로그인하기가 더 비즈니스적인 이름 같아서 변경했어
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이름 바꾼건 좋은것 같아용!! 근데 동사를 앞에 넣어서 LoginAutomaticallyUseCase 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거는 잘 모르겠어!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UseCase는 앞에 동사가 오는걸 원칙으로 하면 일관성 있지 않을까요???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 동사가 앞에 오는게 일관성 있는것 같습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한 번만 봐줘 ㅠㅠㅠ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
봐줬다😏