Websocket Controllers + Auth


#1

Both of these things work:

Ws.channel('chat', ({auth}) => console.log(auth.user)).middleware(['auth'])
Ws.channel('chat:*', 'ChatController').middleware(['auth'])

But what I can’t figure out is how to make the “auth” object available inside my ChatController.

class ChatController {
  constructor ({ socket, request, auth }) {  //auth is undefined
    this.socket = socket
    this.request = request
  }

  onMessage (message, auth) { //auth is undefined
    let user = auth.user
    this.socket.broadcastToAll('message', message)
  }
}

This doesn’t seem to be a problem with Http controllers, but with web socket controllers I’m out of luck. Any ideas?


#2

Nevermind. Auth seemed to work correctly in the constructor.


#3

It doesn’t work for me. How did you do that?