feat: add hide dotfiles param (#1148)

This commit is contained in:
Tiger Nie 2020-11-20 18:51:28 +08:00 committed by GitHub
parent dcbc3286e2
commit 10e399b3c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 11 deletions

View file

@ -26,6 +26,7 @@ type userInfo struct {
Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"`
LockPassword bool `json:"lockPassword"`
HideDotfiles bool `json:"hideDotfiles"`
}
type authToken struct {
@ -175,6 +176,7 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
Perm: user.Perm,
LockPassword: user.LockPassword,
Commands: user.Commands,
HideDotfiles: user.HideDotfiles,
},
StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Unix(),

View file

@ -7,6 +7,7 @@ import (
"github.com/tomasen/realip"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/runner"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage"
@ -26,6 +27,10 @@ type data struct {
// Check implements rules.Checker.
func (d *data) Check(path string) bool {
if d.user.HideDotfiles && rules.MatchHidden(path) {
return false
}
allow := true
for _, rule := range d.settings.Rules {
if rule.Matches(path) {