-
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.
Browse files
Browse the repository at this point in the history
Feature/jaino/#87
- Loading branch information
Showing
22 changed files
with
186 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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/main/java/com/wap/wapp/core/data/repository/auth/AuthRepository.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,11 +1,9 @@ | ||
package com.wap.wapp.core.data.repository.auth | ||
|
||
interface AuthRepository { | ||
suspend fun hasPendingResult(): Boolean | ||
|
||
suspend fun signIn(email: String): Result<String> | ||
|
||
suspend fun signOut(): Result<Unit> | ||
|
||
suspend fun deleteUser(): Result<Unit> | ||
|
||
suspend fun isUserSignIn(): Result<Boolean> | ||
} |
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
5 changes: 5 additions & 0 deletions
5
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,5 @@ | ||
package com.wap.wapp.core.data.repository.auth | ||
|
||
interface SignInRepository { | ||
suspend fun signIn(email: String): Result<String> | ||
} |
10 changes: 10 additions & 0 deletions
10
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,10 @@ | ||
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 signIn(email: String): Result<String> = signInDataSource.signIn(email) | ||
} |
10 changes: 10 additions & 0 deletions
10
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/IsUserSignInUseCase.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,10 @@ | ||
package com.wap.wapp.core.domain.usecase.auth | ||
|
||
import com.wap.wapp.core.data.repository.auth.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class IsUserSignInUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
) { | ||
suspend operator fun invoke(): Result<Boolean> = authRepository.isUserSignIn() | ||
} |
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/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSource.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,11 +1,9 @@ | ||
package com.wap.wapp.core.network.source.auth | ||
|
||
interface AuthDataSource { | ||
suspend fun hasPendingResult(): Boolean | ||
|
||
suspend fun signIn(email: String): Result<String> | ||
|
||
suspend fun signOut(): Result<Unit> | ||
|
||
suspend fun deleteUser(): Result<Unit> | ||
|
||
suspend fun isUserSignIn(): Result<Boolean> | ||
} |
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
5 changes: 5 additions & 0 deletions
5
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,5 @@ | ||
package com.wap.wapp.core.network.source.auth | ||
|
||
interface SignInDataSource { | ||
suspend fun signIn(email: String): Result<String> | ||
} |
30 changes: 30 additions & 0 deletions
30
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,30 @@ | ||
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 signIn(email: String): Result<String> = | ||
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 | ||
} | ||
} |
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
Oops, something went wrong.