-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] #87 : ActivityComponent에 주입되는 모듈 분리 및 로직 분리
- Loading branch information
1 parent
a8072cb
commit 962d4c6
Showing
6 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignInRepository.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,7 @@ | ||
package com.wap.wapp.core.data.repository.auth | ||
|
||
interface SignInRepository { | ||
suspend fun hasPendingResult(): Boolean | ||
|
||
suspend fun signIn(email: String): Result<String> | ||
} |
12 changes: 12 additions & 0 deletions
12
core/data/src/main/java/com/wap/wapp/core/data/repository/auth/SignInRepositoryImpl.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,12 @@ | ||
package com.wap.wapp.core.data.repository.auth | ||
|
||
import com.wap.wapp.core.network.source.auth.SignInDataSource | ||
import javax.inject.Inject | ||
|
||
class SignInRepositoryImpl @Inject constructor( | ||
private val signInDataSource: SignInDataSource, | ||
) : SignInRepository { | ||
override suspend fun hasPendingResult(): Boolean = signInDataSource.hasPendingResult() | ||
|
||
override suspend fun signIn(email: String): Result<String> = signInDataSource.signIn(email) | ||
} |
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
7 changes: 7 additions & 0 deletions
7
core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSource.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,7 @@ | ||
package com.wap.wapp.core.network.source.auth | ||
|
||
interface SignInDataSource { | ||
suspend fun hasPendingResult(): Boolean | ||
|
||
suspend fun signIn(email: String): Result<String> | ||
} |
35 changes: 35 additions & 0 deletions
35
core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSourceImpl.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,35 @@ | ||
package com.wap.wapp.core.network.source.auth | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import com.google.firebase.auth.FirebaseAuth | ||
import com.google.firebase.auth.OAuthProvider | ||
import com.wap.wapp.core.network.utils.await | ||
import dagger.hilt.android.qualifiers.ActivityContext | ||
import javax.inject.Inject | ||
|
||
class SignInDataSourceImpl @Inject constructor( | ||
private val firebaseAuth: FirebaseAuth, | ||
@ActivityContext private val context: Context, | ||
) : SignInDataSource { | ||
override suspend fun hasPendingResult(): Boolean { | ||
return firebaseAuth.pendingAuthResult != null | ||
} | ||
|
||
override suspend fun signIn(email: String): Result<String> { | ||
return runCatching { | ||
val provider = OAuthProvider.newBuilder("github.com") | ||
provider.addCustomParameter("login", email) | ||
|
||
val activityContext = context as Activity | ||
|
||
val result = firebaseAuth.startActivityForSignInWithProvider( | ||
activityContext, | ||
provider.build(), | ||
).await() | ||
|
||
val user = checkNotNull(result.user) | ||
user.uid | ||
} | ||
} | ||
} |