Check for websocket token before connecting to chat

Closes #403. Previously, a socket to the chat channel would be opened if
chat is enabled, regardless if the user is logged in or not. This patch
only allows a connection to be opened if a wsToken (websocket token) is
present, which prevents websocket errors from unauthenticated users.
This commit is contained in:
slice 2019-03-10 01:54:26 -08:00
parent 09736691ea
commit a67881b096
No known key found for this signature in database
GPG Key ID: 1508C19D7436A26D
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ const api = {
},
initializeSocket (store) {
// Set up websocket connection
if (!store.state.chatDisabled) {
if (!store.state.chatDisabled && store.state.wsToken) {
const token = store.state.wsToken
const socket = new Socket('/socket', {params: {token}})
socket.connect()