mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-13 10:55:05 +02:00
Handle socket re-authentication, fix socket toast to be re-usable, socket cleanup
This commit is contained in:
parent
a24dae5262
commit
e201247d69
5 changed files with 66 additions and 16 deletions
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue