mirror of
https://github.com/home-assistant/android
synced 2024-10-15 12:32:54 +00:00
Only use the base URL during onboarding if the URL is Nabu Casa (#3322)
* Only use the base URL during onboarding * Use HttpUrl Builder to construct proper URL * Move variable to try/catch block * Only apply logic to NC URLs as those do not have custom path * Only parse the end of the URL * Deduplicate code per review
This commit is contained in:
parent
50a8b9eee2
commit
9ece6c7c28
|
@ -33,6 +33,7 @@ import io.homeassistant.companion.android.onboarding.integration.MobileAppIntegr
|
|||
import io.homeassistant.companion.android.themes.ThemesManager
|
||||
import io.homeassistant.companion.android.util.TLSWebViewClient
|
||||
import io.homeassistant.companion.android.util.isStarted
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import javax.inject.Inject
|
||||
import io.homeassistant.companion.android.common.R as commonR
|
||||
|
@ -166,8 +167,16 @@ class AuthenticationFragment : Fragment() {
|
|||
|
||||
private fun buildAuthUrl(base: String): String {
|
||||
return try {
|
||||
base.toHttpUrl()
|
||||
.newBuilder()
|
||||
val url = base.toHttpUrl()
|
||||
val builder = if (url.host.endsWith("ui.nabu.casa", true)) {
|
||||
HttpUrl.Builder()
|
||||
.scheme(url.scheme)
|
||||
.host(url.host)
|
||||
.port(url.port)
|
||||
} else {
|
||||
url.newBuilder()
|
||||
}
|
||||
builder
|
||||
.addPathSegments("auth/authorize")
|
||||
.addEncodedQueryParameter("response_type", "code")
|
||||
.addEncodedQueryParameter("client_id", AuthenticationService.CLIENT_ID)
|
||||
|
|
Loading…
Reference in a new issue