-
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.
- Loading branch information
Showing
11 changed files
with
59 additions
and
37 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
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
23 changes: 23 additions & 0 deletions
23
data/auth/src/main/java/com/easyhz/noffice/data/auth/strategy/AuthStrategyContext.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,23 @@ | ||
package com.easyhz.noffice.data.auth.strategy | ||
|
||
import android.content.Context | ||
import com.easyhz.noffice.data.auth.util.Provider | ||
import javax.inject.Inject | ||
|
||
class AuthStrategyContext @Inject constructor( | ||
private val strategies: Map<String, @JvmSuppressWildcards BaseStrategy> | ||
) { | ||
private var currentStrategy: BaseStrategy = strategies[Provider.GOOGLE.name]!! | ||
|
||
fun setStrategy(provider: String) { | ||
currentStrategy = strategies[provider] ?: throw IllegalArgumentException("Invalid provider") | ||
} | ||
|
||
suspend fun login(context: Context): Result<String> { | ||
return currentStrategy.login(context) | ||
} | ||
|
||
suspend fun logout(context: Context): Result<Unit> { | ||
return currentStrategy.logout(context) | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
domain/sign/src/main/java/com/easyhz/noffice/domain/sign/usecase/LoginUseCase.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,13 +1,13 @@ | ||
package com.easyhz.noffice.domain.sign.usecase | ||
|
||
import android.content.Context | ||
import com.easyhz.noffice.core.common.base.BaseUseCase | ||
import com.easyhz.noffice.core.model.auth.param.AuthParam | ||
import com.easyhz.noffice.data.auth.repository.login.LoginRepository | ||
import javax.inject.Inject | ||
|
||
class LoginUseCase @Inject constructor( | ||
private val loginRepository: LoginRepository | ||
): BaseUseCase<Context, Unit>() { | ||
override suspend fun invoke(param: Context): Result<Unit> = | ||
loginRepository.loginWithGoogle(param) | ||
): BaseUseCase<AuthParam , Unit>() { | ||
override suspend fun invoke(param: AuthParam): Result<Unit> = | ||
loginRepository.login(param.context, param.providerName) | ||
} |
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