mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-05 00:18:30 +01:00
Fix:Disconnect from socket on logout, remove unnecessary logout function
This commit is contained in:
parent
bf66e13377
commit
e47ea98cdd
@ -82,9 +82,11 @@ export default {
|
|||||||
this.$setLanguageCode(lang)
|
this.$setLanguageCode(lang)
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
var rootSocket = this.$root.socket || {}
|
// Disconnect from socket
|
||||||
const logoutPayload = {
|
if (this.$root.socket) {
|
||||||
socketId: rootSocket.id
|
console.log('Disconnecting from socket', this.$root.socket.id)
|
||||||
|
this.$root.socket.removeAllListeners()
|
||||||
|
this.$root.socket.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localStorage.getItem('token')) {
|
if (localStorage.getItem('token')) {
|
||||||
@ -93,17 +95,20 @@ export default {
|
|||||||
this.$store.commit('libraries/setUserPlaylists', [])
|
this.$store.commit('libraries/setUserPlaylists', [])
|
||||||
this.$store.commit('libraries/setCollections', [])
|
this.$store.commit('libraries/setCollections', [])
|
||||||
|
|
||||||
this.$axios.$post('/logout').then((logoutPayload) => {
|
this.$axios
|
||||||
const redirect_url = logoutPayload.redirect_url
|
.$post('/logout')
|
||||||
|
.then((logoutPayload) => {
|
||||||
|
const redirect_url = logoutPayload.redirect_url
|
||||||
|
|
||||||
if (redirect_url) {
|
if (redirect_url) {
|
||||||
window.location.href = redirect_url
|
window.location.href = redirect_url
|
||||||
} else {
|
} else {
|
||||||
this.$router.push('/login')
|
this.$router.push('/login')
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
})
|
||||||
console.error(error)
|
.catch((error) => {
|
||||||
})
|
console.error(error)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.password = null
|
this.password = null
|
||||||
|
@ -219,25 +219,6 @@ class SocketAuthority {
|
|||||||
client.socket.emit('init', initialPayload)
|
client.socket.emit('init', initialPayload)
|
||||||
}
|
}
|
||||||
|
|
||||||
logout(socketId) {
|
|
||||||
// Strip user and client from client and client socket
|
|
||||||
if (socketId && this.clients[socketId]) {
|
|
||||||
const client = this.clients[socketId]
|
|
||||||
const clientSocket = client.socket
|
|
||||||
Logger.debug(`[SocketAuthority] Found user client ${clientSocket.id}, Has user: ${!!client.user}, Socket has client: ${!!clientSocket.sheepClient}`)
|
|
||||||
|
|
||||||
if (client.user) {
|
|
||||||
Logger.debug('[SocketAuthority] User Offline ' + client.user.username)
|
|
||||||
this.adminEmitter('user_offline', client.user.toJSONForPublic())
|
|
||||||
}
|
|
||||||
|
|
||||||
delete this.clients[socketId].user
|
|
||||||
if (clientSocket && clientSocket.sheepClient) delete this.clients[socketId].socket.sheepClient
|
|
||||||
} else if (socketId) {
|
|
||||||
Logger.warn(`[SocketAuthority] No client for socket ${socketId}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelScan(id) {
|
cancelScan(id) {
|
||||||
Logger.debug('[SocketAuthority] Cancel scan', id)
|
Logger.debug('[SocketAuthority] Cancel scan', id)
|
||||||
this.Server.cancelLibraryScan(id)
|
this.Server.cancelLibraryScan(id)
|
||||||
|
Loading…
Reference in New Issue
Block a user