Skip to content

Commit

Permalink
Auth: Catch exceptions in AssistedSignInFragment (#2446)
Browse files Browse the repository at this point in the history
Fixes #2424
  • Loading branch information
DaVinci9196 authored and ysfchn committed Aug 8, 2024
1 parent f6a7b27 commit 3d9adcb
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ class AssistedSignInFragment(
private fun filterAccountsLogin(multiMethod: (List<Account>) -> Unit, loginMethod: (Account, Boolean) -> Unit) {
lifecycleScope.launch {
val allowAutoLoginAccounts = mutableListOf<Account>()
accounts.forEach { account ->
val authStatus = checkAppAuthStatus(requireContext(), clientPackageName, options, account)
if (authStatus) {
allowAutoLoginAccounts.add(account)
runCatching {
accounts.forEach { account ->
val authStatus = checkAppAuthStatus(requireContext(), clientPackageName, options, account)
if (authStatus) {
allowAutoLoginAccounts.add(account)
}
}
}.onFailure {
Log.d(TAG, "filterAccountsLogin: error", it)
errorBlock(Status(CommonStatusCodes.INTERNAL_ERROR, "auth error"))
return@launch
}
if (accounts.size == 1) {
loginMethod(accounts.first(), allowAutoLoginAccounts.isNotEmpty())
Expand Down Expand Up @@ -255,15 +261,20 @@ class AssistedSignInFragment(
lastChooseAccountPermitted = permitted
isSigningIn = true
delay(3000)
val googleSignInAccount = withContext(Dispatchers.IO) {
performSignIn(requireContext(), clientPackageName, options, account, permitted)
}
if (googleSignInAccount == null) {
isSigningIn = false
prepareChooseLogin(account, showConsent = true, permitted = true)
return@launch
runCatching {
val googleSignInAccount = withContext(Dispatchers.IO) {
performSignIn(requireContext(), clientPackageName, options, account, permitted)
}
if (googleSignInAccount == null) {
isSigningIn = false
prepareChooseLogin(account, showConsent = true, permitted = true)
return@launch
}
loginBlock(googleSignInAccount)
}.onFailure {
Log.d(TAG, "startLogin: error", it)
errorBlock(Status(CommonStatusCodes.INTERNAL_ERROR, "signIn error"))
}
loginBlock(googleSignInAccount)
}
}

Expand Down

0 comments on commit 3d9adcb

Please sign in to comment.