Login user with socket a socket request

Is there any way by login a user with an socket request and then return the token. After the token is returned, is the client is authed or do i need to reconnect the socket with the token?

I need this cause i have some public channels that dosen’t need auth and is displayed/used before the user is logged in.

I believe, you have to perform re-connect, since the authentication details can be passed when you call .connect on client side.

1 Like

Thank you for the suggestion.

What about updating the request object? like this:


      let token = await this.auth.withRefreshToken().attempt(_user.username, _user.password)
      this.request.request.headers['authorization'] = 'Bearer ' + token.token;
      this.socket.emit('loginSuccess', token);



Is it bad practice? But it seems to work good =)