From 830bf7dff7ada51454ef020170cf07566aada513 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 3 Sep 2018 18:26:20 +0200 Subject: Improved fuel configuration :wrench: --- app/src/main/java/me/texx/Texx/RoutingActivity.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/me') diff --git a/app/src/main/java/me/texx/Texx/RoutingActivity.kt b/app/src/main/java/me/texx/Texx/RoutingActivity.kt index 86ad359..01e407e 100644 --- a/app/src/main/java/me/texx/Texx/RoutingActivity.kt +++ b/app/src/main/java/me/texx/Texx/RoutingActivity.kt @@ -31,6 +31,10 @@ class RoutingActivity : AppCompatActivity() { super.onCreate(savedInstanceState) dressCodeName = getThemeName(this) + // Fuel configuration + val accessToken: String? = SecureStorage(this@RoutingActivity).get("access_token") + if (accessToken != null) + FuelManager.instance.baseHeaders = mapOf("Authorization" to "Bearer $accessToken") FuelManager.instance.basePath = "http://$serverAddress" if (EasyPrefrences(this@RoutingActivity).getBoolean("previously_started")) { @@ -65,12 +69,11 @@ class RoutingActivity : AppCompatActivity() { } private fun verifyLogin() { - val accessToken: String? = SecureStorage(this@RoutingActivity).get("access_token") + val accessToken: String? = SecureStorage(this@RoutingActivity).get("access_token") // because it may be the first start // synced function of fuel doesn't work here (#331) -> ugly workaround if (accessToken != null) { val userID = EasyPrefrences(this@RoutingActivity).getString("user_id") - "/users/$userID".httpGet() // verify by making request to user api - .header("Authorization" to "Bearer $accessToken") + "/users/$userID".httpGet() // verify by making request to user api // TODO: More secure way of verifying .responseJson { _, response, result -> val (_, serverError) = result when { // TODO: Cleaner task solution -- cgit v1.2.3