Fix multiple server status messages

This commit is contained in:
Matthew Penner 2020-06-10 15:00:59 -06:00
parent 0ae286d617
commit 5c2686fc6d

View File

@ -218,15 +218,28 @@ func (h *Handler) HandleInbound(m Message) error {
return err return err
} }
if token.HasPermission(PermissionConnect) { // Check if the user has previously authenticated successfully.
h.setJwt(token) newConnection := h.GetJwt() == nil
}
// Previously there was a HasPermission(PermissionConnect) check around this,
// however NewTokenPayload will return an error if it doesn't have the connect
// permission meaning that it was a redundant function call.
h.setJwt(token)
// Tell the client they authenticated successfully.
h.unsafeSendJson(Message{ h.unsafeSendJson(Message{
Event: AuthenticationSuccessEvent, Event: AuthenticationSuccessEvent,
Args: []string{}, Args: []string{},
}) })
// Check if the client was refreshing their authentication token
// instead of authenticating for the first time.
if !newConnection {
// This prevents duplicate status messages as outlined in
// https://github.com/pterodactyl/panel/issues/2077
return nil
}
// On every authentication event, send the current server status back // On every authentication event, send the current server status back
// to the client. :) // to the client. :)
state := h.server.GetState() state := h.server.GetState()