mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-07-17 16:36:49 +00:00
fix: check download permission when sharing permission is enabled (#5875)
This commit is contained in:
parent
860c19ddf5
commit
0f39bd055e
4 changed files with 29 additions and 2 deletions
|
|
@ -156,6 +156,10 @@ var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
|
|||
return http.StatusBadRequest, err
|
||||
}
|
||||
|
||||
if req.Data.Perm.Share && !req.Data.Perm.Download {
|
||||
return http.StatusBadRequest, fberrors.ErrShareRequiresDownload
|
||||
}
|
||||
|
||||
userHome, err := d.settings.MakeUserDir(req.Data.Username, req.Data.Scope, d.server.Root)
|
||||
if err != nil {
|
||||
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
|
||||
|
|
@ -204,6 +208,14 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
|||
return http.StatusBadRequest, nil
|
||||
}
|
||||
|
||||
for _, field := range req.Which {
|
||||
if strings.ToLower(field) == "perm" || strings.ToLower(field) == "all" {
|
||||
if req.Data.Perm.Share && !req.Data.Perm.Download {
|
||||
return http.StatusBadRequest, fberrors.ErrShareRequiresDownload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(req.Which) == 0 || (len(req.Which) == 1 && req.Which[0] == "all") {
|
||||
if !d.user.Perm.Admin {
|
||||
return http.StatusForbidden, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue