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" SendServerLogsEvent = "send logs"
SendCommandEvent = "send command" SendCommandEvent = "send command"
ErrorEvent = "daemon error" ErrorEvent = "daemon error"
JwtErrorEvent = "jwt error"
) )
type Message struct { 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! // Do not send JSON down the line if the JWT on the connection is not valid!
if err := h.TokenValid(); err != nil { if err := h.TokenValid(); err != nil {
h.unsafeSendJson(Message{ h.unsafeSendJson(Message{
Event: ErrorEvent, Event: JwtErrorEvent,
Args: []string{"could not authenticate client: " + err.Error()}, Args: []string{err.Error()},
}) })
return nil return nil
@ -244,8 +244,8 @@ func (h *Handler) HandleInbound(m Message) error {
if m.Event != AuthenticationEvent { if m.Event != AuthenticationEvent {
if err := h.TokenValid(); err != nil { if err := h.TokenValid(); err != nil {
h.unsafeSendJson(Message{ h.unsafeSendJson(Message{
Event: ErrorEvent, Event: JwtErrorEvent,
Args: []string{"could not authenticate client: " + err.Error()}, Args: []string{err.Error()},
}) })
return nil return nil