Pass redirect_to param on auth (#1361)

Co-authored-by: Ben Toogood <ben@micro.mu>
This commit is contained in:
ben-toogood 2020-03-17 20:04:16 +00:00 committed by GitHub
parent 00cd2448a4
commit cd04111e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,9 @@
package auth package auth
import ( import (
"fmt"
"net/http" "net/http"
"net/url"
"strings" "strings"
"github.com/micro/go-micro/v2/auth" "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 // 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)
} }