From 0f39bd055efdadc15abd2f8146cf5da3793f8318 Mon Sep 17 00:00:00 2001
From: Ariel Leyva
- + {{ $t("settings.perm.download") }}
@@ -61,5 +65,15 @@ export default { }, isExecEnabled: () => enableExec, }, + watch: { + perm: { + deep: true, + handler() { + if (this.perm.share === true) { + this.perm.download = true; + } + }, + }, + }, }; diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index dcbedcef..933c2e32 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -245,7 +245,7 @@ "execute": "Execute commands", "modify": "Edit files", "rename": "Rename or move files and directories", - "share": "Share files" + "share": "Share files (require download permission)" }, "permissions": "Permissions", "permissionsHelp": "You can set the user to be an administrator or choose the permissions individually. If you select \"Administrator\", all of the other options will be automatically checked. The management of users remains a privilege of an administrator.\n", diff --git a/http/users.go b/http/users.go index be1edf91..e61ab00b 100644 --- a/http/users.go +++ b/http/users.go @@ -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