auth/middleware: return semantic errors on auth failure This time with a much simpler approach than the last one that caused some authentication issues for chat.sr.ht.
1 files changed, 3 insertions(+), 2 deletions(-) M auth/middleware.go
M auth/middleware.go => auth/middleware.go +3 -2
@@ 101,11 101,12 @@ func (authctx *AuthContext) Access(scope, kind string) error { } func authError(w http.ResponseWriter, reason string, code int) { gqlerr := gqlerror.Errorf("Authentication error: %s", reason) b, err := json.Marshal(struct { Errors []*gqlerror.Error `json:"errors"` }{ Errors: []*gqlerror.Error{gqlerr}, Errors: []*gqlerror.Error{ errors.New(errors.Unauthorized, reason), }, }) if err != nil { panic(err)