fix: adminKey ignored
This commit is contained in:
@@ -31,14 +31,14 @@ object LNbitsClient {
|
||||
|
||||
fun create(secrets: SecretStore): LNbitsApi {
|
||||
// Auth header interceptor — reads invoice key per-request (unchanged)
|
||||
val authInterceptor = Interceptor { chain ->
|
||||
val key = runBlocking { secrets.invoiceKey() }
|
||||
chain.proceed(
|
||||
chain.request().newBuilder()
|
||||
.header("X-Api-Key", key)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
// val authInterceptor = Interceptor { chain ->
|
||||
// val key = runBlocking { secrets.invoiceKey() }
|
||||
// chain.proceed(
|
||||
// chain.request().newBuilder()
|
||||
// .header("X-Api-Key", key)
|
||||
// .build()
|
||||
// )
|
||||
// }
|
||||
|
||||
// Dynamic base URL interceptor — rewrites the placeholder host to the
|
||||
// real base URL at request time, not at Retrofit construction time.
|
||||
@@ -65,7 +65,7 @@ object LNbitsClient {
|
||||
}
|
||||
|
||||
val client = httpClient.newBuilder()
|
||||
.addInterceptor(authInterceptor)
|
||||
// .addInterceptor(authInterceptor)
|
||||
.addInterceptor(dynamicBaseUrlInterceptor)
|
||||
.apply {
|
||||
// Logging goes LAST — after URL rewrite — so logs show the real URL
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.bitcointxoko.gudariwallet.data.HistoricalSyncStore
|
||||
import com.bitcointxoko.gudariwallet.security.SecretStore
|
||||
import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorker
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
private const val PAGE_WELCOME = 0
|
||||
private const val PAGE_SERVER_URL = 1
|
||||
@@ -64,20 +65,20 @@ fun OnboardingScreen(
|
||||
|
||||
LaunchedEffect(pagerState.currentPage) { error = null }
|
||||
|
||||
var previousPage by remember { mutableIntStateOf(0) }
|
||||
LaunchedEffect(pagerState.currentPage) {
|
||||
val current = pagerState.currentPage
|
||||
if (current > previousPage) {
|
||||
// User moved forward — save whatever the previous page owned
|
||||
when (previousPage) {
|
||||
PAGE_SERVER_URL -> secretStore.saveBaseUrl(baseUrl)
|
||||
PAGE_INVOICE -> secretStore.saveInvoiceKey(invoiceKey)
|
||||
PAGE_ADMIN -> secretStore.saveAdminKey(adminKey)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
previousPage = current
|
||||
}
|
||||
// var previousPage by remember { mutableIntStateOf(0) }
|
||||
// LaunchedEffect(pagerState.currentPage) {
|
||||
// val current = pagerState.currentPage
|
||||
// if (current > previousPage) {
|
||||
// // User moved forward — save whatever the previous page owned
|
||||
// when (previousPage) {
|
||||
// PAGE_SERVER_URL -> secretStore.saveBaseUrl(baseUrl)
|
||||
// PAGE_INVOICE -> secretStore.saveInvoiceKey(invoiceKey)
|
||||
// PAGE_ADMIN -> secretStore.saveAdminKey(adminKey)
|
||||
// else -> Unit
|
||||
// }
|
||||
// }
|
||||
// previousPage = current
|
||||
// }
|
||||
|
||||
fun validateCurrentPage(): Boolean {
|
||||
error = when (pagerState.currentPage) {
|
||||
@@ -172,11 +173,19 @@ fun OnboardingScreen(
|
||||
Button(onClick = {
|
||||
if (!validateCurrentPage()) return@Button
|
||||
scope.launch {
|
||||
// Save each field as soon as the user advances past it
|
||||
when (pagerState.currentPage) {
|
||||
PAGE_SERVER_URL -> secretStore.saveBaseUrl(baseUrl)
|
||||
PAGE_INVOICE -> secretStore.saveInvoiceKey(invoiceKey)
|
||||
PAGE_ADMIN -> secretStore.saveAdminKey(adminKey)
|
||||
PAGE_SERVER_URL -> {
|
||||
Timber.d("ONBOARDING saving baseUrl (len=${baseUrl.length}): $baseUrl")
|
||||
secretStore.saveBaseUrl(baseUrl)
|
||||
}
|
||||
PAGE_INVOICE -> {
|
||||
Timber.d("ONBOARDING saving invoiceKey (len=${invoiceKey.length}): $invoiceKey")
|
||||
secretStore.saveInvoiceKey(invoiceKey)
|
||||
}
|
||||
PAGE_ADMIN -> {
|
||||
Timber.d("ONBOARDING saving adminKey (len=${adminKey.length}): $adminKey")
|
||||
secretStore.saveAdminKey(adminKey)
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
pagerState.animateScrollToPage(pagerState.currentPage + 1)
|
||||
|
||||
Reference in New Issue
Block a user