Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚑 Fix auto logout #307

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,7 +39,7 @@ class TrwlCheckInProvider: CheckInProvider<TrwlCheckInResponse>() {

override val client = httpClientBuilder
.addInterceptor(ErrorInterceptor())
.addInterceptor(AuthInterceptor(TraewellingApi.jwt))
.addInterceptor(AuthInterceptor())
.build()
override val retrofit: Retrofit = Retrofit.Builder()
.addConverterFactory(ZonedDateTimeRetrofitConverterFactory.create())
Expand Down