-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: AuthInterceptor 구현 중 * chore: 코드 포맷 * feat: 네트워크 통신을 위한 인터셉터 구현 * feat: 구글 로그인을 통해 access 토근을 받아오는 로직 구현 * feat: signUP 구현 * feat : navigateToLogin 로직 삭제 * feat : 테마 패키지 수정 * feat : suspendOnError를 suspendOnFailure로 수정 * feat : 구글 로그인 에러시 error메세지를 띄우도록 변경 * ci 문법 오류 수정 --------- Co-authored-by: kwakjoohyeong <[email protected]> Co-authored-by: chws0508 <[email protected]>
- Loading branch information
1 parent
35f3db2
commit 813a5c2
Showing
46 changed files
with
460 additions
and
122 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[*.{kt,kts}] | ||
ij_kotlin_allow_trailing_comma=true | ||
ij_kotlin_allow_trailing_comma_on_call_site=true | ||
ktlint_function_naming_ignore_when_annotated_with=Composable, Test | ||
ij_kotlin_allow_trailing_comma = true | ||
ij_kotlin_allow_trailing_comma_on_call_site = true | ||
ktlint_function_naming_ignore_when_annotated_with = Composable, Test |
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,8 +1,11 @@ | ||
## 관련 이슈번호 | ||
|
||
<br/> close # | ||
|
||
## 작업 사항 | ||
|
||
<br/> | ||
|
||
## 기타 사항 | ||
|
||
<br/> |
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
6 changes: 2 additions & 4 deletions
6
app/src/androidTest/java/com/withpeace/withpeace/ExampleInstrumentedTest.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
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
6 changes: 2 additions & 4 deletions
6
core/data/src/androidTest/java/com/withpeace/withpeace/core/data/ExampleInstrumentedTest.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
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,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<manifest> | ||
|
||
</manifest> |
18 changes: 18 additions & 0 deletions
18
core/data/src/main/kotlin/com/withpeace/withpeace/core/data/di/RepositoryModule.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,18 @@ | ||
package com.withpeace.withpeace.core.data.di | ||
|
||
import com.withpeace.withpeace.core.data.repository.DefaultTokenRepository | ||
import com.withpeace.withpeace.core.domain.repository.TokenRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
interface RepositoryModule { | ||
|
||
@Binds | ||
@Singleton | ||
fun bindsTokenRepository(defaultTokenRepository: DefaultTokenRepository): TokenRepository | ||
} |
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
83 changes: 54 additions & 29 deletions
83
...ta/src/main/kotlin/com/withpeace/withpeace/core/data/repository/DefaultTokenRepository.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,49 +1,74 @@ | ||
package com.withpeace.withpeace.core.data.repository | ||
|
||
import com.skydoves.sandwich.message | ||
import com.skydoves.sandwich.messageOrNull | ||
import com.skydoves.sandwich.suspendMapSuccess | ||
import com.skydoves.sandwich.suspendOnError | ||
import com.skydoves.sandwich.suspendOnFailure | ||
import com.withpeace.withpeace.core.data.mapper.toDomain | ||
import com.withpeace.withpeace.core.datastore.dataStore.TokenPreferenceDataSource | ||
import com.withpeace.withpeace.core.domain.model.Token | ||
import com.withpeace.withpeace.core.domain.repository.TokenRepository | ||
import com.withpeace.withpeace.core.network.di.request.SignUpRequest | ||
import com.withpeace.withpeace.core.network.di.service.AuthService | ||
import com.withpeace.withpeace.core.network.di.service.LoginService | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import javax.inject.Inject | ||
|
||
class DefaultTokenRepository | ||
@Inject | ||
constructor( | ||
private val tokenPreferenceDataSource: TokenPreferenceDataSource, | ||
private val loginService: LoginService, | ||
private val authService: AuthService, | ||
) : TokenRepository { | ||
override fun getAccessToken(): Flow<String?> { | ||
return tokenPreferenceDataSource.accessToken | ||
} | ||
|
||
class DefaultTokenRepository @Inject constructor( | ||
private val tokenPreferenceDataSource: TokenPreferenceDataSource, | ||
private val authService: AuthService | ||
) : TokenRepository { | ||
override fun getRefreshToken(): Flow<String?> { | ||
return tokenPreferenceDataSource.refreshToken | ||
} | ||
|
||
override fun getAccessToken(): Flow<String?> { | ||
return tokenPreferenceDataSource.accessToken | ||
} | ||
override suspend fun updateAccessToken(accessToken: String) { | ||
tokenPreferenceDataSource.updateAccessToken(accessToken) | ||
} | ||
|
||
override fun getRefreshToken(): Flow<String?> { | ||
return tokenPreferenceDataSource.refreshToken | ||
} | ||
override suspend fun updateRefreshToken(refreshToken: String) { | ||
tokenPreferenceDataSource.updateRefreshToken(refreshToken) | ||
} | ||
|
||
override suspend fun updateAccessToken(accessToken: String) { | ||
tokenPreferenceDataSource.updateAccessToken(accessToken) | ||
} | ||
override suspend fun signUp( | ||
email: String, | ||
nickname: String, | ||
deviceToken: String?, | ||
) { | ||
authService.signUp( | ||
SignUpRequest( | ||
email = email, | ||
nickname = nickname, | ||
deviceToken = deviceToken, | ||
), | ||
) | ||
} | ||
|
||
override suspend fun updateRefreshToken(refreshToken: String) { | ||
tokenPreferenceDataSource.updateRefreshToken(refreshToken) | ||
} | ||
override fun googleLogin( | ||
idToken: String, | ||
onError: (String?) -> Unit, | ||
): Flow<Token> = | ||
flow { | ||
loginService.googleLogin(AUTHORIZATION_FORMAT.format(idToken)) | ||
.suspendMapSuccess { | ||
emit(data.toDomain()) | ||
updateAccessToken(data.accessToken) | ||
updateRefreshToken(data.refreshToken) | ||
}.suspendOnFailure { | ||
onError(messageOrNull) | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
|
||
override fun googleLogin(onError: (String?) -> Unit): Flow<Token> = flow { | ||
authService.googleLogin() | ||
.suspendMapSuccess { | ||
emit(data.toDomain()) | ||
updateAccessToken(data.accessToken) | ||
updateRefreshToken(data.refreshToken) | ||
}.suspendOnError { | ||
onError(message()) | ||
} | ||
}.flowOn(Dispatchers.IO) | ||
} | ||
companion object { | ||
private const val AUTHORIZATION_FORMAT = "Bearer %s" | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
core/data/src/test/java/com/withpeace/withpeace/core/data/ExampleUnitTest.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
6 changes: 2 additions & 4 deletions
6
...re/src/androidTest/java/com/withpeace/withpeace/core/datastore/ExampleInstrumentedTest.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
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,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<manifest> | ||
|
||
</manifest> |
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
3 changes: 1 addition & 2 deletions
3
core/datastore/src/test/java/com/withpeace/withpeace/core/datastore/ExampleUnitTest.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
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 @@ | ||
/build |
Oops, something went wrong.