From a722353bb68f8aad228d9d48693ef76331172ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20G=C3=A4hwiler?= Date: Sun, 29 Apr 2018 12:35:36 +0300 Subject: [PATCH] properly return not authorized error --- broker/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/broker/client.go b/broker/client.go index 748d24f..e4dcb52 100644 --- a/broker/client.go +++ b/broker/client.go @@ -23,6 +23,9 @@ const ( // ConnectPacket. var ErrExpectedConnect = errors.New("expected a ConnectPacket as the first packet") +// ErrNotAuthorized is returned when a client is not authorized. +var ErrNotAuthorized = errors.New("client is not authorized") + // ErrMissingSession is returned if the backend does not return a session. var ErrMissingSession = errors.New("no session returned from Backend") @@ -206,7 +209,7 @@ func (c *Client) processConnect(pkt *packet.ConnectPacket) error { } // close client - return c.die(ClientError, nil, true) + return c.die(ClientError, ErrNotAuthorized, true) } // set state