Merge pull request #35 from pterodactyl/issue/2077

Fix multiple server status messages
This commit is contained in:
Dane Everitt 2020-06-11 20:52:15 -07:00 committed by GitHub
commit e1531802cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,15 +218,28 @@ func (h *Handler) HandleInbound(m Message) error {
return err
}
if token.HasPermission(PermissionConnect) {
h.setJwt(token)
}
// Check if the user has previously authenticated successfully.
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{
Event: AuthenticationSuccessEvent,
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
// to the client. :)
state := h.server.GetState()