|
|
@@ -6,14 +6,12 @@ import com.adealink.frame.base.IError
|
|
|
import com.adealink.frame.base.Rlt
|
|
|
import com.adealink.frame.coroutine.dispatcher.Dispatcher
|
|
|
import com.adealink.frame.frame.BaseFrame
|
|
|
-import com.adealink.frame.locale.country.getSimCountryCode
|
|
|
import com.adealink.frame.locale.language.languageManager
|
|
|
import com.adealink.frame.log.Log
|
|
|
import com.adealink.frame.network.ISocketNotify
|
|
|
import com.adealink.frame.network.data.Res
|
|
|
import com.adealink.frame.router.Router
|
|
|
import com.adealink.frame.util.AppUtil
|
|
|
-import com.adealink.frame.util.getSimMmc
|
|
|
import com.adealink.tcturing.TCTuringManager
|
|
|
import com.adealink.weparty.App
|
|
|
import com.adealink.weparty.account.ban.banManager
|
|
|
@@ -29,7 +27,7 @@ import com.adealink.weparty.account.login.data.EmailLoginReq
|
|
|
import com.adealink.weparty.account.login.data.EmailResetPwdReq
|
|
|
import com.adealink.weparty.account.login.data.GetEmailReq
|
|
|
import com.adealink.weparty.account.login.data.GetVerifyCodeReq
|
|
|
-import com.adealink.weparty.account.login.data.LoginReq
|
|
|
+import com.adealink.weparty.account.login.data.GoogleLoginReq
|
|
|
import com.adealink.weparty.account.login.data.LoginResult
|
|
|
import com.adealink.weparty.account.login.data.PhoneLoginReq
|
|
|
import com.adealink.weparty.account.login.data.RefreshTokenNotify
|
|
|
@@ -60,10 +58,10 @@ import com.adealink.weparty.module.attribution.AttributionModule
|
|
|
import com.adealink.weparty.module.profile.ProfileModule
|
|
|
import com.adealink.weparty.setting.data.EmailState
|
|
|
import com.adealink.weparty.storage.AppPref
|
|
|
+import com.adealink.weparty.ui.home.util.HomeLocalService
|
|
|
import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.withContext
|
|
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
|
-import com.adealink.weparty.ui.home.util.HomeLocalService
|
|
|
|
|
|
val loginManager: ILoginManager by lazy { LoginManager() }
|
|
|
|
|
|
@@ -196,38 +194,69 @@ class LoginManager : BaseFrame<ILoginListener>(), ILoginManager {
|
|
|
tid: Long?,
|
|
|
codeVerifier: String?
|
|
|
): Rlt<Res<LoginResult>> {
|
|
|
- val newDeviceId = App.instance.deviceIdService.getNewDeviceIdErrorEmpty()
|
|
|
- val isEmulator = App.instance.securityService.isEmulator()
|
|
|
- val isVirtualApk = App.instance.securityService.isVirtualApk()
|
|
|
- val appsflyerId = AttributionModule.getAppsFlyerUID()
|
|
|
- val deviceToken = TCTuringManager.getDeviceToken()
|
|
|
- var tidReq: Long? = null //用户登录tid
|
|
|
- Log.i(TAG_ACCOUNT_LOGIN, "login, isVirtualApk:${isVirtualApk}, isEmulator${isEmulator}")
|
|
|
- var loginReq = LoginReq(
|
|
|
- accessToken = token,
|
|
|
- thirdType = authType.value,
|
|
|
- deviceId = getLoginDeviceId(),
|
|
|
- newDeviceId = newDeviceId,
|
|
|
- country = getSimCountryCode() ?: "",
|
|
|
- simulator = isEmulator,
|
|
|
- virtualApk = isVirtualApk,
|
|
|
- appsflyerId = appsflyerId,
|
|
|
- appLang = languageManager?.getLanguageCode() ?: "",
|
|
|
- systemLang = languageManager?.getSystemLanguageCode() ?: "",
|
|
|
- simMcc = getSimMmc(),
|
|
|
- tid = tid,
|
|
|
- deviceToken = deviceToken,
|
|
|
- codeVerifier = codeVerifier,
|
|
|
- inviter = inviteUidCode,
|
|
|
- shareScene = shareScene
|
|
|
- )
|
|
|
- val rlt = loginService.login(
|
|
|
- loginReq
|
|
|
+
|
|
|
+ when (authType) {
|
|
|
+ ThirdType.GOOGLE -> {
|
|
|
+ return googleLogin(token)
|
|
|
+ }
|
|
|
+
|
|
|
+ ThirdType.FB -> {}
|
|
|
+ ThirdType.APPLE -> {}
|
|
|
+ ThirdType.PHONE -> {}
|
|
|
+ ThirdType.EMAIL -> {}
|
|
|
+ ThirdType.TIKTOK -> {}
|
|
|
+ }
|
|
|
+
|
|
|
+// val newDeviceId = App.instance.deviceIdService.getNewDeviceIdErrorEmpty()
|
|
|
+// val isEmulator = App.instance.securityService.isEmulator()
|
|
|
+// val isVirtualApk = App.instance.securityService.isVirtualApk()
|
|
|
+// val appsflyerId = AttributionModule.getAppsFlyerUID()
|
|
|
+// val deviceToken = TCTuringManager.getDeviceToken()
|
|
|
+// var tidReq: Long? = null //用户登录tid
|
|
|
+// Log.i(TAG_ACCOUNT_LOGIN, "login, isVirtualApk:${isVirtualApk}, isEmulator${isEmulator}")
|
|
|
+// var loginReq = LoginReq(
|
|
|
+// accessToken = token,
|
|
|
+// thirdType = authType.value,
|
|
|
+// deviceId = getLoginDeviceId(),
|
|
|
+// newDeviceId = newDeviceId,
|
|
|
+// country = getSimCountryCode() ?: "",
|
|
|
+// simulator = isEmulator,
|
|
|
+// virtualApk = isVirtualApk,
|
|
|
+// appsflyerId = appsflyerId,
|
|
|
+// appLang = languageManager?.getLanguageCode() ?: "",
|
|
|
+// systemLang = languageManager?.getSystemLanguageCode() ?: "",
|
|
|
+// simMcc = getSimMmc(),
|
|
|
+// tid = tid,
|
|
|
+// deviceToken = deviceToken,
|
|
|
+// codeVerifier = codeVerifier,
|
|
|
+// inviter = inviteUidCode,
|
|
|
+// shareScene = shareScene
|
|
|
+// )
|
|
|
+// val rlt = loginService.login(
|
|
|
+// loginReq
|
|
|
+// )
|
|
|
+// if (rlt is Rlt.Success) {
|
|
|
+// val res = rlt.data.data
|
|
|
+// if (res != null) {
|
|
|
+// loginSuccess(res, authType)
|
|
|
+// notifyLogin()
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return rlt
|
|
|
+ return Rlt.Failed(IError("不支持"))
|
|
|
+ }
|
|
|
+
|
|
|
+ private suspend fun googleLogin(token: String): Rlt<Res<LoginResult>> {
|
|
|
+ Log.d(TAG_ACCOUNT_LOGIN, "googleLogin, token:$token")
|
|
|
+ val rlt = loginService.googleLogin(
|
|
|
+ GoogleLoginReq(
|
|
|
+ token = token
|
|
|
+ )
|
|
|
)
|
|
|
if (rlt is Rlt.Success) {
|
|
|
val res = rlt.data.data
|
|
|
if (res != null) {
|
|
|
- loginSuccess(res, authType)
|
|
|
+ loginSuccess(res, ThirdType.GOOGLE)
|
|
|
notifyLogin()
|
|
|
}
|
|
|
}
|
|
|
@@ -239,35 +268,37 @@ class LoginManager : BaseFrame<ILoginListener>(), ILoginManager {
|
|
|
password: String,
|
|
|
countryCode: String,
|
|
|
): Rlt<Res<LoginResult>> {
|
|
|
- val newDeviceId = App.instance.deviceIdService.getNewDeviceIdErrorEmpty()
|
|
|
- val isEmulator = App.instance.securityService.isEmulator()
|
|
|
- val isVirtualApk = App.instance.securityService.isVirtualApk()
|
|
|
- val appsflyerId = AttributionModule.getAppsFlyerUID()
|
|
|
- val deviceToken = TCTuringManager.getDeviceToken()
|
|
|
- val rlt = loginService.phoneLogin(
|
|
|
- PhoneLoginReq(
|
|
|
- phone,
|
|
|
- password,
|
|
|
- "",
|
|
|
- getLoginDeviceId(),
|
|
|
- newDeviceId,
|
|
|
- countryCode,
|
|
|
- simulator = isEmulator,
|
|
|
- virtualApk = isVirtualApk,
|
|
|
- appsflyerId = appsflyerId,
|
|
|
- deviceToken = deviceToken,
|
|
|
- inviter = inviteUidCode,
|
|
|
- shareScene = shareScene
|
|
|
- )
|
|
|
- )
|
|
|
- if (rlt is Rlt.Success) {
|
|
|
- val res = rlt.data.data
|
|
|
- if (res != null) {
|
|
|
- loginSuccess(res, ThirdType.PHONE)
|
|
|
- notifyLogin()
|
|
|
- }
|
|
|
- }
|
|
|
- return rlt
|
|
|
+// val newDeviceId = App.instance.deviceIdService.getNewDeviceIdErrorEmpty()
|
|
|
+// val isEmulator = App.instance.securityService.isEmulator()
|
|
|
+// val isVirtualApk = App.instance.securityService.isVirtualApk()
|
|
|
+// val appsflyerId = AttributionModule.getAppsFlyerUID()
|
|
|
+// val deviceToken = TCTuringManager.getDeviceToken()
|
|
|
+// val rlt = loginService.phoneLogin(
|
|
|
+// PhoneLoginReq(
|
|
|
+// phone,
|
|
|
+// password,
|
|
|
+// "",
|
|
|
+// getLoginDeviceId(),
|
|
|
+// newDeviceId,
|
|
|
+// countryCode,
|
|
|
+// simulator = isEmulator,
|
|
|
+// virtualApk = isVirtualApk,
|
|
|
+// appsflyerId = appsflyerId,
|
|
|
+// deviceToken = deviceToken,
|
|
|
+// inviter = inviteUidCode,
|
|
|
+// shareScene = shareScene
|
|
|
+// )
|
|
|
+// )
|
|
|
+// if (rlt is Rlt.Success) {
|
|
|
+// val res = rlt.data.data
|
|
|
+// if (res != null) {
|
|
|
+// loginSuccess(res, ThirdType.PHONE)
|
|
|
+// notifyLogin()
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return rlt
|
|
|
+ return Rlt.Failed(IError("不支持"))
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private fun loginSuccess(result: LoginResult, loginType: ThirdType) {
|