Handle re-authenticating socket

This commit is contained in:
advplyr committed 2025-07-06 11:32:21 -05:00
1 parent d35dd2df1a
commit 4534ffaead
2 files changed
+22 -4

No files matched your search

+8 -1
View File
@@ -1,6 +1,6 @@
import { CapacitorHttp } from '@capacitor/core'
export default function ({ store, $db }, inject) {
export default function ({ store, $db, $socket }, inject) {
const nativeHttp = {
async request(method, _url, data, options = {}) {
// When authorizing before a config is set, server config gets passed in as an option
@@ -184,6 +184,13 @@ export default function ({ store, $db }, inject) {
// Update the store
store.commit('user/setAccessToken', tokens.accessToken)
// Re-authenticate socket if necessary
if ($socket?.connected && !$socket.isAuthenticated) {
$socket.sendAuthenticate()
} else if (!$socket) {
console.warn('[nativeHttp] Socket not available, cannot re-authenticate')
}
if (savedConfig) {
store.commit('user/setServerConnectionConfig', savedConfig)
}