Skip to content

Commit 539eb5f

Browse files
authored
Merge pull request #61 from YAPP-Github/feat/#57-google-login
구글 로그인 기능 구현
2 parents 4439d01 + 755644e commit 539eb5f

File tree

28 files changed

+600
-20
lines changed

28 files changed

+600
-20
lines changed

.github/workflows/android-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ jobs:
4848
env:
4949
DEV_BASE_URL: ${{ secrets.DEV_BASE_URL }}
5050
PROD_BASE_URL: ${{ secrets.PROD_BASE_URL }}
51+
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
5152
run: |
5253
echo "dev_base_url=$DEV_BASE_URL" >> local.properties
5354
echo "prod_base_url=$PROD_BASE_URL" >> local.properties
55+
echo "google_client_id=$GOOGLE_CLIENT_ID" >> local.properties
5456
5557
- name: Create google-services.json
5658
env:

core/datastore/src/main/java/com/twix/datastore/AuthConfigure.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ import java.io.OutputStream
1111

1212
@Serializable
1313
internal data class AuthConfigure(
14-
val accessToken: String =
15-
"eyJhbGciOiJIUzM4NCJ9." +
16-
"eyJzdWIiOiIxIiwidHlwZSI6ImFjY2VzcyIsImlhdCI6MTc3MDI0NzM0NCwiZXhwIjoxNzcwODUyMTQ0fQ." +
17-
"67rDscm8BeayYFA1gfcEMliEdEh8-HTUyE5TwmAT8Ef8ZvtaWczxpMNZqI5htiek",
18-
val refreshToken: String =
19-
"eyJhbGciOiJIUzM4NCJ9." +
20-
"eyJzdWIiOiIxIiwidHlwZSI6InJlZnJlc2giLCJpYXQiOjE3NzAyNDczNDQsImV4cCI6MTc3MDg1MjE0NH0." +
21-
"zgUYdR6onyeY5EaH2_pWLs1rjNLf8m8ZeXsY7Cbk99a_2tzR0rDBZO_hdGTnorRL",
14+
val accessToken: String = "",
15+
val refreshToken: String = "",
2216
)
2317

2418
internal object AuthConfigureSerializer : Serializer<AuthConfigure> {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="16dp"
3+
android:height="16dp"
4+
android:viewportWidth="16"
5+
android:viewportHeight="16">
6+
<path
7+
android:pathData="M15.028,7.842C15.028,7.298 14.979,6.775 14.889,6.273H7.668V9.239H11.794C11.616,10.197 11.076,11.009 10.264,11.553V13.477H12.742C14.192,12.142 15.028,10.177 15.028,7.842Z"
8+
android:fillColor="#4285F4"
9+
android:fillType="evenOdd"/>
10+
<path
11+
android:pathData="M7.668,15.333C9.738,15.333 11.473,14.646 12.742,13.476L10.264,11.552C9.577,12.012 8.699,12.284 7.668,12.284C5.671,12.284 3.981,10.935 3.378,9.123H0.816V11.109C2.078,13.615 4.671,15.333 7.668,15.333Z"
12+
android:fillColor="#34A853"
13+
android:fillType="evenOdd"/>
14+
<path
15+
android:pathData="M3.377,9.124C3.223,8.664 3.136,8.173 3.136,7.668C3.136,7.162 3.223,6.671 3.377,6.211V4.225H0.815C0.296,5.26 0,6.431 0,7.668C0,8.905 0.296,10.076 0.815,11.111L3.377,9.124Z"
16+
android:fillColor="#FBBC05"
17+
android:fillType="evenOdd"/>
18+
<path
19+
android:pathData="M7.668,3.049C8.793,3.049 9.804,3.436 10.598,4.196L12.797,1.997C11.47,0.76 9.734,0 7.668,0C4.671,0 2.078,1.718 0.816,4.224L3.378,6.21C3.981,4.398 5.671,3.049 7.668,3.049Z"
20+
android:fillColor="#EA4335"
21+
android:fillType="evenOdd"/>
22+
</vector>

core/navigation/src/main/java/com/twix/navigation/AppNavHost.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fun AppNavHost() {
2323
}
2424
val start =
2525
contributors
26-
.firstOrNull { it.graphRoute == NavRoutes.MainGraph }
26+
.firstOrNull { it.graphRoute == NavRoutes.LoginGraph }
2727
?.graphRoute
2828
?: error("해당 Graph를 찾을 수 없습니다.")
2929
val duration = 300

core/network/src/main/java/com/twix/network/model/request/LoginRequest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import kotlinx.serialization.Serializable
44

55
@Serializable
66
data class LoginRequest(
7-
val code: String,
7+
val idToken: String,
88
)

core/network/src/main/java/com/twix/network/service/AuthService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import de.jensklingenberg.ktorfit.http.Body
88
import de.jensklingenberg.ktorfit.http.POST
99

1010
interface AuthService {
11-
@POST("auth/google")
11+
@POST("auth/google/token")
1212
suspend fun googleLogin(
1313
@Body request: LoginRequest,
1414
): LoginResponse

data/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ android {
88

99
dependencies {
1010
implementation(projects.core.datastore)
11+
implementation(projects.core.token)
1112
}

data/src/main/java/com/twix/data/di/RepositoryModule.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.twix.data.di
22

3+
import com.twix.data.repository.DefaultAuthRepository
34
import com.twix.data.repository.DefaultOnboardingRepository
5+
import com.twix.domain.repository.AuthRepository
46
import com.twix.domain.repository.OnBoardingRepository
57
import org.koin.dsl.module
68

@@ -9,4 +11,7 @@ internal val repositoryModule =
911
single<OnBoardingRepository> {
1012
DefaultOnboardingRepository(get())
1113
}
14+
single<AuthRepository> {
15+
DefaultAuthRepository(get(), get())
16+
}
1217
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.twix.data.repository
2+
3+
import com.twix.domain.login.LoginType
4+
import com.twix.domain.repository.AuthRepository
5+
import com.twix.network.model.request.LoginRequest
6+
import com.twix.network.service.AuthService
7+
import com.twix.token.TokenProvider
8+
9+
class DefaultAuthRepository(
10+
private val service: AuthService,
11+
private val tokenProvider: TokenProvider,
12+
) : AuthRepository {
13+
override suspend fun login(
14+
idToken: String,
15+
type: LoginType,
16+
) {
17+
val response =
18+
when (type) {
19+
LoginType.GOOGLE -> service.googleLogin(LoginRequest(idToken))
20+
LoginType.KAKAO -> return
21+
}
22+
23+
tokenProvider.saveToken(response.accessToken, response.refreshToken)
24+
}
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.twix.domain.login
2+
3+
interface LoginProvider {
4+
suspend fun login(): LoginResult
5+
6+
suspend fun logout(): Result<Unit>
7+
}

0 commit comments

Comments
 (0)