diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/me/texx/Texx/RoutingActivity.kt | 9 |
1 files changed, 6 insertions, 3 deletions
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 |