WebClient: redirect to the requested URL after login

This feature is only useful and enabled for file manager urls

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-06-08 18:14:47 +02:00
parent f938af5a61
commit 9d60972743
7 changed files with 217 additions and 53 deletions

View File

@@ -18,6 +18,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"strings"
"github.com/go-chi/jwtauth/v5"
@@ -52,6 +53,9 @@ func validateJWTToken(w http.ResponseWriter, r *http.Request, audience tokenAudi
redirectPath = webAdminLoginPath
} else {
redirectPath = webClientLoginPath
if uri := r.RequestURI; strings.HasPrefix(uri, webClientFilesPath) {
redirectPath += "?next=" + url.QueryEscape(uri)
}
}
isAPIToken := (audience == tokenAudienceAPI || audience == tokenAudienceAPIUser)