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
+25
View File
@@ -245,10 +245,35 @@ Vue.prototype.$sanitizeSlug = (str) => {
return str
}
/**
* Compares two semantic versioning strings to determine if the current version meets
* or exceeds the minimum version requirement.
* Only supports 3 part versions, e.g. "1.2.3"
*
* @param {string} currentVersion - The current version string to compare, e.g., "1.2.3".
* @param {string} minVersion - The minimum version string required, e.g., "1.0.0".
* @returns {boolean} - Returns true if the current version is greater than or equal
* to the minimum version, false otherwise.
*/
function isValidVersion(currentVersion, minVersion) {
if (!currentVersion || !minVersion) return false
const currentParts = currentVersion.split('.').map(Number)
const minParts = minVersion.split('.').map(Number)
for (let i = 0; i < minParts.length; i++) {
if (currentParts[i] > minParts[i]) return true
if (currentParts[i] < minParts[i]) return false
}
return true
}
export default ({ store, app }, inject) => {
const eventBus = new Vue()
inject('eventBus', eventBus)
inject('isValidVersion', isValidVersion)
// Set theme
app.$localStore?.getTheme()?.then((theme) => {
if (theme) {
+8 -2
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') {