Send JWT errors as specific event type

This commit is contained in:
Dane Everitt 2020-09-27 09:09:34 -07:00
parent 4748d7cb29
commit 3655b172f3
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 5 additions and 4 deletions

View File

@ -9,6 +9,7 @@ const (
SendServerLogsEvent = "send logs"
SendCommandEvent = "send command"
ErrorEvent = "daemon error"
JwtErrorEvent = "jwt error"
)
type Message struct {

View File

@ -109,8 +109,8 @@ func (h *Handler) SendJson(v *Message) error {
// Do not send JSON down the line if the JWT on the connection is not valid!
if err := h.TokenValid(); err != nil {
h.unsafeSendJson(Message{
Event: ErrorEvent,
Args: []string{"could not authenticate client: " + err.Error()},
Event: JwtErrorEvent,
Args: []string{err.Error()},
})
return nil
@ -244,8 +244,8 @@ func (h *Handler) HandleInbound(m Message) error {
if m.Event != AuthenticationEvent {
if err := h.TokenValid(); err != nil {
h.unsafeSendJson(Message{
Event: ErrorEvent,
Args: []string{"could not authenticate client: " + err.Error()},
Event: JwtErrorEvent,
Args: []string{err.Error()},
})
return nil