mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-11-21 16:01:33 +01:00
Handle re-authenticating socket
This commit is contained in:
1 parent
d35dd2df1a
commit
4534ffaead
2 files changed
+22
-4
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user