@@ -603,26 +603,33 @@ open class LoginActivity : FragmentActivity() {
603603 }
604604 }
605605
606- private fun handleBackBehavior () {
607- // If app is using Native Login this activity is a fallback and can be dismissed.
608- if (SalesforceSDKManager .getInstance().nativeLoginActivity != null ) {
609- setResult(RESULT_CANCELED )
610- finish()
611- return // If we don't call return here moveTaskToBack can also be called below.
612- }
606+ internal fun handleBackBehavior () {
607+ with (SalesforceSDKManager .getInstance()) {
608+ // If app is using Native Login this activity is a fallback and can be dismissed.
609+ if (nativeLoginActivity != null ) {
610+ setResult(RESULT_CANCELED )
611+ finish()
612+ return // If we don't call return here moveTaskToBack can also be called below.
613+ }
613614
614- // Do nothing if locked
615- if (SalesforceSDKManager .getInstance().biometricAuthenticationManager?.locked == false ) {
616- /*
617- * If there are no accounts signed in, the login screen needs to go
618- * away and go back to the home screen. However, if the login screen
619- * has been brought up from the switcher screen, the back button
620- * should take the user back to the previous screen.
621- */
622- wasBackgrounded = true
623- when (SalesforceSDKManager .getInstance().userAccountManager.authenticatedUsers) {
624- null -> moveTaskToBack(true )
625- else -> finish()
615+ // Do nothing if locked
616+ if (biometricAuthenticationManager?.locked == false ) {
617+ /*
618+ * If there are no accounts signed in, the login screen needs to go
619+ * away and go back to the home screen. However, if the login screen
620+ * has been brought up from the switcher screen, the back button
621+ * should take the user back to the previous screen.
622+ *
623+ * shouldShowBackButton normally checks for authenticated users,
624+ * but trust the app if it has been overridden.
625+ */
626+ wasBackgrounded = true
627+ if (userAccountManager.authenticatedUsers != null || viewModel.shouldShowBackButton) {
628+ setResult(RESULT_CANCELED )
629+ finish()
630+ } else {
631+ moveTaskToBack(true )
632+ }
626633 }
627634 }
628635 }
0 commit comments