Update to not logout from server when switching servers, force users to re-login if using old auth

This commit is contained in:
advplyr 2025-07-05 11:21:20 -05:00
parent 44613e12f1
commit f6e2e4010f
7 changed files with 105 additions and 45 deletions

View file

@ -28,6 +28,7 @@ export default function ({ store, $db }, inject) {
delete options.headers
}
console.log(`[nativeHttp] Making ${method} request to ${url}`)
return CapacitorHttp.request({
method,
url,
@ -177,7 +178,7 @@ export default function ({ store, $db }, inject) {
refreshToken: tokens.refreshToken
}
// Save updated config to secure storage
// Save updated config to secure storage, persists refresh token in secure storage
const savedConfig = await $db.setServerConnectionConfig(updatedConfig)
// Update the store
@ -204,7 +205,12 @@ export default function ({ store, $db }, inject) {
console.log('[nativeHttp] Handling refresh failure - logging out user')
// Logout from server and clear store
await store.dispatch('user/logout', { serverConnectionConfigId })
await store.dispatch('user/logout')
if (serverConnectionConfigId) {
// Clear refresh token for server connection config
await $db.clearRefreshToken(serverConnectionConfigId)
}
// Redirect to login page
if (window.location.pathname !== '/connect') {