From 489d0c54ebcc9aaa4fa294d6ade70d3e36f7192e Mon Sep 17 00:00:00 2001 From: Steve Richter Date: Mon, 21 Jun 2021 21:50:11 -0400 Subject: [PATCH] Show user-friendly message when error occurs in Last.fm callback endpoint --- core/agents/lastfm/auth_router.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/agents/lastfm/auth_router.go b/core/agents/lastfm/auth_router.go index 4cd4f41a1..04f033580 100644 --- a/core/agents/lastfm/auth_router.go +++ b/core/agents/lastfm/auth_router.go @@ -9,6 +9,7 @@ import ( "github.com/deluan/rest" "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" "github.com/navidrome/navidrome/conf" "github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/model" @@ -100,7 +101,9 @@ func (s *Router) callback(w http.ResponseWriter, r *http.Request) { ctx := r.Context() err := s.fetchSessionKey(ctx, uid, token) if err != nil { - _ = rest.RespondWithError(w, http.StatusBadRequest, err.Error()) + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.WriteHeader(http.StatusBadRequest) + _, _ = w.Write([]byte("An error occurred while authorizing with Last.fm. \n\nRequest ID: " + middleware.GetReqID(ctx))) return }