Allow password entry for shared directories

This commit is contained in:
2026-10-05 17:39:39 +02:00
parent 6f0f58d2d9
commit f3738cbc4d
8 changed files with 91 additions and 24 deletions

View File

@@ -32,8 +32,13 @@ func (wc *WebController) serveDirectory(w http.ResponseWriter, r *http.Request,
td.User = json.RawMessage("null")
}
// A shared link can have the password of the directory in it
var path = strings.TrimPrefix(p.ByName("path"), "/")
var err = pdapi.GetJSON("filesystem/"+url.PathEscape(path)+"?stat", &td.Node)
var err = pdapi.GetJSON(
"filesystem/"+url.PathEscape(path)+"?stat&password="+
url.QueryEscape(r.URL.Query().Get("password")),
&td.Node,
)
if apiErr, ok := errors.AsType[pixelapi.Error](err); ok {
// Set the proper response code for the error message
switch apiErr.StatusCode {