From cd04111e3d56f8ecc284e70e282810bb2950bf3a Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 17 Mar 2020 20:04:16 +0000 Subject: [PATCH] Pass redirect_to param on auth (#1361) Co-authored-by: Ben Toogood --- api/server/auth/auth.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/server/auth/auth.go b/api/server/auth/auth.go index 81697214..e89f0233 100644 --- a/api/server/auth/auth.go +++ b/api/server/auth/auth.go @@ -1,7 +1,9 @@ package auth import ( + "fmt" "net/http" + "net/url" "strings" "github.com/micro/go-micro/v2/auth" @@ -83,5 +85,7 @@ func (h authHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } // Redirect to the login path - http.Redirect(w, req, loginURL, http.StatusTemporaryRedirect) + params := url.Values{"redirect_to": {req.URL.Path}} + loginWithRedirect := fmt.Sprintf("%v?%v", loginURL, params.Encode()) + http.Redirect(w, req, loginWithRedirect, http.StatusTemporaryRedirect) }