File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -10,19 +10,22 @@ const config = {
1010 }
1111} ;
1212
13- export const updateSocketAuthToken = ( token ) => {
13+ if ( Storage . hasToken ( ) ) {
1414 config . auth . headers = {
15- Authorization : `Bearer ${ token } `
15+ Authorization : `Bearer ${ Storage . getToken ( ) } `
1616 } ;
17- } ;
18-
19- if ( Storage . hasToken ( ) ) {
20- updateSocketAuthToken ( Storage . getToken ( ) ) ;
2117}
2218
23-
2419export const pusher = new Pusher ( process . env . VUE_APP_PUSHER_APP_KEY , config ) ;
2520
2621export const getSocketId = ( ) => {
2722 return pusher . connection . socket_id ;
2823} ;
24+
25+ export const updateSocketAuthToken = ( token ) => {
26+ pusher . config . auth . headers . Authorization = `Bearer ${ token } ` ;
27+ } ;
28+
29+ export const removeSocketAuthToken = ( ) => {
30+ pusher . config . auth . headers = { } ;
31+ }
Original file line number Diff line number Diff line change 11import { USER_LOGIN , USER_LOGOUT , SET_AUTHENTICATED_USER } from './mutationTypes' ;
22import Storage from '@/services/Storage' ;
33import { emptyUser , userMapper } from '@/services/Normalizer' ;
4- import { updateSocketAuthToken } from '@/services/Pusher' ;
4+ import { updateSocketAuthToken , removeSocketAuthToken } from '@/services/Pusher' ;
55
66export default {
77 [ USER_LOGIN ] : ( state , accessToken ) => {
@@ -14,6 +14,7 @@ export default {
1414
1515 [ USER_LOGOUT ] : state => {
1616 Storage . removeToken ( ) ;
17+ removeSocketAuthToken ( ) ;
1718
1819 state . token = '' ;
1920 state . isLoggedIn = false ;
You can’t perform that action at this time.
0 commit comments