Профиль, редактирование без аватара

This commit is contained in:
Халимов Рустам
2026-04-16 15:41:22 +03:00
parent 8409c51842
commit cea3f4d669
45 changed files with 1063 additions and 178 deletions

View File

@@ -5,10 +5,15 @@ import okhttp3.Interceptor
import okhttp3.Response
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.launch
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@Singleton
class AuthInterceptor @Inject constructor(
private val tokenManager: TokenManager
private val tokenManager: TokenManager,
private val navigationManager: core.utils.NavigationManager,
private val authRepositoryProvider: javax.inject.Provider<auth.domain.repository.AuthRepository>
) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val token = tokenManager.getToken()
@@ -17,6 +22,17 @@ class AuthInterceptor @Inject constructor(
addHeader("Authorization", "Bearer $it")
}
}.build()
return chain.proceed(request)
val response = chain.proceed(request)
if (response.code == 401) {
// Global logout
kotlinx.coroutines.GlobalScope.launch(kotlinx.coroutines.Dispatchers.Main) {
authRepositoryProvider.get().logout()
navigationManager.logout()
}
}
return response
}
}