Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #2395 - Adds an early return statement and documents why we copy …
Browse files Browse the repository at this point in the history
…a feature
  • Loading branch information
boek committed Jun 5, 2019
1 parent a6eadab commit 612106b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import mozilla.components.service.fxa.manager.FxaAccountManager
import org.mozilla.fenix.settings.SupportUtils
import kotlin.coroutines.CoroutineContext

// The FirefoxAccountsAuthFeature provided by android components only worked with
// the tabs use case. We want to use our custom tab feature to improve the UX for both
// signing in through settings and onboarding.

// We're temporarily copying and creating our own:
// https://github.com/mozilla-mobile/android-components/issues/3272
class FirefoxAccountsAuthFeature(
private val accountManager: FxaAccountManager,
private val redirectUrl: String,
Expand All @@ -32,7 +38,7 @@ class FirefoxAccountsAuthFeature(
CoroutineScope(coroutineContext).launch {
// FIXME return a fallback URL provided by Config...
// https://github.com/mozilla-mobile/android-components/issues/2496
val authUrl = beginAuthentication() ?: "https://accounts.firefox.com/signin"
val authUrl = beginAuthentication() ?: FALLBACK_URL

// TODO
// We may fail to obtain an authentication URL, for example due to transient network errors.
Expand Down Expand Up @@ -64,4 +70,8 @@ class FirefoxAccountsAuthFeature(
return null
}
}

companion object {
private const val FALLBACK_URL = "https://accounts.firefox.com/signin"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TurnOnSyncFragment : PreferenceFragmentCompat(), AccountObserver {
super.onResume()
if (requireComponents.backgroundServices.accountManager.authenticatedAccount() != null) {
findNavController(this).popBackStack()
return
}

requireComponents.backgroundServices.accountManager.register(this, owner = this)
Expand Down

0 comments on commit 612106b

Please sign in to comment.