From bacc0eebb57a27edde94db09e50eb848af2e7498 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 2 Sep 2016 14:53:06 +0100 Subject: [PATCH] Return Authenticated:false rather than 404ing on missing sessions - it makes life much easier --- src/github.com/matrix-org/go-neb/api.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/api.go b/src/github.com/matrix-org/go-neb/api.go index 4ff7dca..6cb690a 100644 --- a/src/github.com/matrix-org/go-neb/api.go +++ b/src/github.com/matrix-org/go-neb/api.go @@ -359,12 +359,14 @@ func (h *getSessionHandler) OnIncomingRequest(req *http.Request) (interface{}, * } session, err := h.db.LoadAuthSessionByUser(body.RealmID, body.UserID) - if err != nil { - if err == sql.ErrNoRows { - return nil, &errors.HTTPError{err, `Session not found`, 404} - } + if err != nil && err != sql.ErrNoRows { return nil, &errors.HTTPError{err, `Failed to load session`, 500} } + if err == sql.ErrNoRows { + return &struct { + Authenticated bool + }{false}, nil + } return &struct { ID string