Skip to content

Commit

Permalink
Make sure we do not send stale tokens on iOS (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin authored Apr 19, 2024
1 parent 6fad725 commit 33b3188
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.androidmakers.store.graphql

import fr.androidmakers.domain.repo.UserRepository

actual suspend fun getIdToken(userRepository: UserRepository): String? {
return userRepository.getIdToken()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.apollographql.apollo3.network.http.HttpInterceptor
import com.apollographql.apollo3.network.http.HttpInterceptorChain
import fr.androidmakers.domain.repo.UserRepository

expect suspend fun getIdToken(userRepository: UserRepository): String?

fun ApolloClient(
sqlNormalizedCacheFactory: SqlNormalizedCacheFactory,
userRepository: UserRepository,
Expand All @@ -25,7 +27,7 @@ fun ApolloClient(
/**
*
*/
val token = userRepository.getIdToken()
val token = getIdToken(userRepository)
if (token != null) {
addHeader("Authorization", "Bearer $token")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.androidmakers.store.graphql

import fr.androidmakers.domain.repo.UserRepository

actual suspend fun getIdToken(userRepository: UserRepository): String? {
// We do not support signin on iOS? make sure that we're not sending a stale token
return null
}

0 comments on commit 33b3188

Please sign in to comment.