aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorMarvin Borner2018-09-03 18:26:20 +0200
committerMarvin Borner2018-09-03 18:26:20 +0200
commit830bf7dff7ada51454ef020170cf07566aada513 (patch)
treef5b6dd63672ba5fccf071efd2b7bbe235cbdbe73 /app/src/main
parente8a1017181a5577e75095fcaeb274665ea992965 (diff)
Improved fuel configuration :wrench:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/me/texx/Texx/RoutingActivity.kt9
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