Commit 73881386 authored by Vlad Filippov's avatar Vlad Filippov Committed by Christian Sadilek
Browse files

Remove extra success path url for the FxA feature

See also https://github.com/mozilla/fxa-content-server/pull/7077
parent 0835821a
......@@ -23,7 +23,6 @@ class FirefoxAccountsAuthFeature(
private val accountManager: FxaAccountManager,
private val tabsUseCases: TabsUseCases,
private val redirectUrl: String,
private val successPath: String,
private val coroutineContext: CoroutineContext = Dispatchers.Main
) {
fun beginAuthentication() {
......@@ -59,20 +58,21 @@ class FirefoxAccountsAuthFeature(
val interceptor = object : RequestInterceptor {
override fun onLoadRequest(session: EngineSession, uri: String): RequestInterceptor.InterceptionResponse? {
if (!uri.startsWith(redirectUrl)) {
return null
}
if (uri.startsWith(redirectUrl)) {
val parsedUri = Uri.parse(uri)
val code = parsedUri.getQueryParameter("code")
if (code != null) {
val state = parsedUri.getQueryParameter("state") as String
val parsedUri = Uri.parse(uri)
val code = parsedUri.getQueryParameter("code") as String
val state = parsedUri.getQueryParameter("state") as String
// Notify the state machine about our success.
accountManager.finishAuthenticationAsync(code, state)
// Notify the state machine about our success.
accountManager.finishAuthenticationAsync(code, state)
return RequestInterceptor.InterceptionResponse.Url(redirectUrl)
}
}
// TODO this can be simplified once https://github.com/mozilla/application-services/issues/305 lands
val successUrl = "${parsedUri.scheme}://${parsedUri.host}/$successPath"
return RequestInterceptor.InterceptionResponse.Url(successUrl)
return null
}
}
}
......@@ -55,7 +55,7 @@ class FirefoxAccountsAuthFeatureTest {
`when`(mockTabs.addTab).thenReturn(mockAddTab)
runBlocking {
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", "somePath", this.coroutineContext)
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", this.coroutineContext)
feature.beginAuthentication()
}
......@@ -70,7 +70,7 @@ class FirefoxAccountsAuthFeatureTest {
`when`(mockTabs.addTab).thenReturn(mockAddTab)
runBlocking {
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", "somePath", this.coroutineContext)
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", this.coroutineContext)
feature.beginPairingAuthentication("auth://pair")
}
......@@ -85,7 +85,7 @@ class FirefoxAccountsAuthFeatureTest {
`when`(mockTabs.addTab).thenReturn(mockAddTab)
runBlocking {
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", "somePath", this.coroutineContext)
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", this.coroutineContext)
feature.beginAuthentication()
}
......@@ -101,7 +101,7 @@ class FirefoxAccountsAuthFeatureTest {
`when`(mockTabs.addTab).thenReturn(mockAddTab)
runBlocking {
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", "somePath", this.coroutineContext)
val feature = FirefoxAccountsAuthFeature(manager, mockTabs, "somePath", this.coroutineContext)
feature.beginPairingAuthentication("auth://pair")
}
......
......@@ -44,6 +44,9 @@ permalink: /changelog/
* Adds `automaticLanguageAdjustment` setting, which should hint to implementations to send
language specific headers to websites. Implementation in `browser-engine-gecko-nightly`.
* **service-firefox-accounts**
* The service no longer accepts a `successPath` option. Instead the service uses the OAuth `redirectUri`.
# 0.49.0
* [Commits](https://github.com/mozilla-mobile/android-components/compare/v0.48.0...v0.49.0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment