From c0f73361c8b42ba03cfd7f308d45e17c3ca1177d Mon Sep 17 00:00:00 2001 From: Jonas Heubuch Date: Mon, 27 Nov 2023 16:31:17 +0100 Subject: [PATCH] :ambulance: Fix auto logout --- app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt | 2 +- .../de/hbch/traewelling/api/interceptors/AuthInterceptor.kt | 5 +++-- .../providers/checkin/traewelling/TrwlCheckInProvider.kt | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt b/app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt index 41687c96..d86a08bb 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt @@ -37,7 +37,7 @@ const val TRWL_BASE_URL = "https://traewelling.de/api/v1/" val HTTP_CLIENT = OkHttpClient.Builder().readTimeout(60, TimeUnit.SECONDS) .addInterceptor(LogInterceptor()) .addInterceptor(ErrorInterceptor()) - .addInterceptor(AuthInterceptor(TraewellingApi.jwt)) + .addInterceptor(AuthInterceptor()) .build() fun getGson(): Gson = GsonBuilder() diff --git a/app/src/main/kotlin/de/hbch/traewelling/api/interceptors/AuthInterceptor.kt b/app/src/main/kotlin/de/hbch/traewelling/api/interceptors/AuthInterceptor.kt index 7c06f971..716f38be 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/api/interceptors/AuthInterceptor.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/api/interceptors/AuthInterceptor.kt @@ -1,16 +1,17 @@ package de.hbch.traewelling.api.interceptors import de.hbch.traewelling.BuildConfig +import de.hbch.traewelling.api.TraewellingApi import okhttp3.Interceptor import okhttp3.Response -class AuthInterceptor(private val token: String) : Interceptor { +class AuthInterceptor() : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val newRequest = chain .request() .newBuilder() - .addHeader("Authorization", "Bearer $token") + .addHeader("Authorization", "Bearer ${TraewellingApi.jwt}") .addHeader( "User-Agent", "${BuildConfig.APPLICATION_ID}/${BuildConfig.VERSION_NAME}" diff --git a/app/src/main/kotlin/de/hbch/traewelling/providers/checkin/traewelling/TrwlCheckInProvider.kt b/app/src/main/kotlin/de/hbch/traewelling/providers/checkin/traewelling/TrwlCheckInProvider.kt index fbc2aa2b..e2fb4218 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/providers/checkin/traewelling/TrwlCheckInProvider.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/providers/checkin/traewelling/TrwlCheckInProvider.kt @@ -3,7 +3,6 @@ package de.hbch.traewelling.providers.checkin.traewelling import de.hbch.traewelling.adapters.ZonedDateTimeRetrofitConverterFactory import de.hbch.traewelling.api.GSON import de.hbch.traewelling.api.TRWL_BASE_URL -import de.hbch.traewelling.api.TraewellingApi import de.hbch.traewelling.api.interceptors.AuthInterceptor import de.hbch.traewelling.api.interceptors.ErrorInterceptor import de.hbch.traewelling.api.models.Data @@ -40,7 +39,7 @@ class TrwlCheckInProvider: CheckInProvider() { override val client = httpClientBuilder .addInterceptor(ErrorInterceptor()) - .addInterceptor(AuthInterceptor(TraewellingApi.jwt)) + .addInterceptor(AuthInterceptor()) .build() override val retrofit: Retrofit = Retrofit.Builder() .addConverterFactory(ZonedDateTimeRetrofitConverterFactory.create())