-
Notifications
You must be signed in to change notification settings - Fork 2
[feat/#135] google login 세팅 #141
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8929711
feature/#135: util import 제거
vvan2 27348a8
feature/#135: google login 세팅
vvan2 0ad351e
feature/#135: home service 변수명 수정
vvan2 f71faa3
feature/#135: google login 세팅
vvan2 658f4c1
feature/#135: home service 함수명 변경
vvan2 c2f6470
feature/#135: google login version
vvan2 ac96d91
feature/#135: google credentials 버전 수정
vvan2 06e30d1
feature/#135: 수정 사항 반영
vvan2 139c122
feature/#135: security 의존성 추가
vvan2 17259d5
feature/#135: datastore 암호화
vvan2 fe270d4
feature/#135: datastore 암호화
vvan2 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
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/paw/key/core/util/suspendRunCating.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,19 @@ | ||
| package com.paw.key.core.util | ||
|
|
||
| import kotlinx.coroutines.TimeoutCancellationException | ||
| import kotlinx.coroutines.ensureActive | ||
| import kotlin.coroutines.cancellation.CancellationException | ||
| import kotlin.coroutines.coroutineContext | ||
|
|
||
| suspend fun <R> suspendRunCatching(block: suspend () -> R): Result<R> { | ||
| return try { | ||
| Result.success(block()) | ||
| } catch (t: TimeoutCancellationException) { | ||
| Result.failure(t) | ||
| } catch (c: CancellationException) { | ||
| throw c | ||
| } catch (e: Throwable) { | ||
| coroutineContext.ensureActive() | ||
| Result.failure(e) | ||
| } | ||
| } |
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/paw/key/data/dto/request/LoginRequestDto.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,17 @@ | ||
| package com.paw.key.data.dto.request | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class LoginRequestDto ( | ||
| @SerialName("email") | ||
| val email: String, | ||
| ) | ||
| // 테스트용입니다 | ||
|
|
||
|
|
||
| fun LoginRequestDto.toEntity(): LoginRequestDto { | ||
| val email = this.email | ||
| return LoginRequestDto(email) | ||
| } |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/paw/key/data/dto/response/LoginResponseDto.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,13 @@ | ||
| package com.paw.key.data.dto.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class LoginResponseDto ( | ||
| @SerialName("AccessToken") | ||
| val AccessToken: String, | ||
| @SerialName("RefreshToken") | ||
| val RefreshToken: String | ||
| ) | ||
| // 테스트용입니다 |
18 changes: 18 additions & 0 deletions
18
...c/main/java/com/paw/key/data/remote/datasource/datasourceimpl/AuthRemoteDataSourceImpl.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,18 @@ | ||
| package com.paw.key.data.remote.datasource.datasourceimpl | ||
|
|
||
| import com.paw.key.data.dto.request.LoginRequestDto | ||
| import com.paw.key.data.dto.response.BaseResponse | ||
| import com.paw.key.data.dto.response.LoginResponseDto | ||
| import com.paw.key.data.remote.datasource.login.AuthRemoteDataSource | ||
| import com.paw.key.data.service.login.LoginService | ||
| import javax.inject.Inject | ||
|
|
||
| class AuthRemoteDataSourceImpl @Inject constructor( | ||
| private val loginService: LoginService, | ||
| ) : AuthRemoteDataSource { | ||
| override suspend fun login( | ||
| providerToken: String, | ||
| provider: String, | ||
| ): BaseResponse<LoginResponseDto> = | ||
| loginService.login(providerToken, LoginRequestDto(provider)) | ||
| } |
36 changes: 36 additions & 0 deletions
36
...c/main/java/com/paw/key/data/remote/datasource/datasourceimpl/GoogleAuthDataSourceImpl.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,36 @@ | ||
| package com.paw.key.data.remote.datasource.datasourceimpl | ||
|
|
||
| import android.content.Context | ||
| import androidx.credentials.CredentialManager | ||
| import androidx.credentials.GetCredentialRequest | ||
| import com.google.android.libraries.identity.googleid.GetGoogleIdOption | ||
| import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential | ||
| import com.paw.key.BuildConfig | ||
| import com.paw.key.core.util.suspendRunCatching | ||
| import com.paw.key.data.dto.request.LoginRequestDto | ||
| import com.paw.key.data.dto.response.BaseResponse | ||
| import com.paw.key.data.dto.response.LoginResponseDto | ||
| import com.paw.key.data.remote.datasource.login.AuthRemoteDataSource | ||
| import com.paw.key.data.remote.datasource.login.GoogleAuthDataSource | ||
| import com.paw.key.data.service.login.LoginService | ||
| import javax.inject.Inject | ||
|
|
||
| class GoogleAuthDataSourceImpl @Inject constructor( | ||
| private val credentialManager: CredentialManager, | ||
| ) : GoogleAuthDataSource { | ||
| override suspend fun signIn(context: Context): Result<GoogleIdTokenCredential> = | ||
| suspendRunCatching { | ||
| val googleIdOption = GetGoogleIdOption.Builder() | ||
| .setFilterByAuthorizedAccounts(false) | ||
| .setAutoSelectEnabled(false) | ||
| .setServerClientId(BuildConfig.GOOGLE_WEB_CLIENT_ID) | ||
| .build() | ||
|
|
||
| val request = GetCredentialRequest.Builder() | ||
| .addCredentialOption(googleIdOption) | ||
| .build() | ||
|
|
||
| val response = credentialManager.getCredential(context, request) | ||
| GoogleIdTokenCredential.createFrom(response.credential.data) | ||
| } | ||
| } |
8 changes: 3 additions & 5 deletions
8
app/src/main/java/com/paw/key/data/remote/datasource/home/RegionCurrentDataSource.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 |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| package com.paw.key.data.remote.datasource.home | ||
|
|
||
| import com.paw.key.data.dto.request.home.HomeRegionRequest | ||
| import com.paw.key.data.service.home.HomeRegionService | ||
| import com.paw.key.data.service.home.RegionCurrentService | ||
| import javax.inject.Inject | ||
|
|
||
| class RegionCurrentDataSource @Inject constructor( | ||
| private val service: RegionCurrentService | ||
| private val service: HomeRegionService | ||
| ) { | ||
| suspend fun RegionCurrent(userId: Int) = | ||
| service.RegionCurrent(userId) | ||
| suspend fun regionCurrent(userId: Int) = | ||
| service.regionCurrent(userId) | ||
| } | ||
|
|
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/paw/key/data/remote/datasource/login/AuthRemoteDataSource.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,8 @@ | ||
| package com.paw.key.data.remote.datasource.login | ||
|
|
||
| import com.paw.key.data.dto.response.BaseResponse | ||
| import com.paw.key.data.dto.response.LoginResponseDto | ||
|
|
||
| interface AuthRemoteDataSource { | ||
| suspend fun login(providerToken: String, provider: String): BaseResponse<LoginResponseDto> | ||
| } |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/paw/key/data/remote/datasource/login/GoogleAuthDataSource.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,10 @@ | ||
| package com.paw.key.data.remote.datasource.login | ||
|
|
||
| import android.content.Context | ||
| import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential | ||
| import com.paw.key.data.dto.response.BaseResponse | ||
| import com.paw.key.data.dto.response.LoginResponseDto | ||
|
|
||
| interface GoogleAuthDataSource { | ||
| suspend fun signIn(context: Context): Result<GoogleIdTokenCredential> | ||
| } |
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.
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.
👍