add copy permission

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-02-20 18:19:09 +01:00
parent e5fc1bd574
commit 51ae2d7301
12 changed files with 95 additions and 21 deletions

View File

@@ -72,6 +72,8 @@ const (
PermChown = "chown"
// changing file or directory access and modification time is allowed
PermChtimes = "chtimes"
// copying files or directories is allowed
PermCopy = "copy"
)
// Available login methods
@@ -1113,6 +1115,21 @@ func (u *User) CanDeleteFromWeb(target string) bool {
return u.HasAnyPerm(permsDeleteAny, target)
}
// CanCopyFromWeb returns true if the client can copy objects from the web UI.
// The specified src and dest are the source and target directories for the copy.
func (u *User) CanCopyFromWeb(src, dest string) bool {
if util.Contains(u.Filters.WebClient, sdk.WebClientWriteDisabled) {
return false
}
if !u.HasPerm(PermListItems, src) {
return false
}
if !u.HasPerm(PermDownload, src) {
return false
}
return u.HasPerm(PermCopy, src) && u.HasPerm(PermCopy, dest)
}
// PasswordExpiresIn returns the number of days before the password expires.
// The returned value is negative if the password is expired.
// The caller must ensure that a PasswordExpiration is set