mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-18 10:59:41 +02:00
Handle socket re-authentication, fix socket toast to be re-usable, socket cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export default function ({ $axios, store, $config, app }) {
|
||||
export default function ({ $axios, store, $root, app }) {
|
||||
// Track if we're currently refreshing to prevent multiple refresh attempts
|
||||
let isRefreshing = false
|
||||
let failedQueue = []
|
||||
@@ -82,6 +82,11 @@ export default function ({ $axios, store, $config, app }) {
|
||||
// Update the token in store and localStorage
|
||||
store.commit('user/setUser', response.user)
|
||||
|
||||
// Emit event used to re-authenticate socket in default.vue since $root is not available here
|
||||
if (app.$eventBus) {
|
||||
app.$eventBus.$emit('token_refreshed', newAccessToken)
|
||||
}
|
||||
|
||||
// Update the original request with new token
|
||||
if (!originalRequest.headers) {
|
||||
originalRequest.headers = {}
|
||||
|
Reference in New Issue
Block a user