fix: check download permission when sharing permission is enabled (#5875)
This commit is contained in:
1 parent
860c19ddf5
commit
0f39bd055e
4 files changed
+29
-2
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user