Send JWT errors as specific event type
This commit is contained in:
parent
4748d7cb29
commit
3655b172f3
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user