fix: give regular users global webdav access
This commit is contained in:
+14
-6
@@ -89,15 +89,23 @@ func (a *App) storageForTask(t *Task) (RemoteStorage, string, bool) {
|
||||
if a.db.First(&user, t.UserID).Error != nil {
|
||||
return nil, "", false
|
||||
}
|
||||
if user.Role == RoleAdmin {
|
||||
if a.cfg.WebDAVURL == "" {
|
||||
return nil, "", false
|
||||
}
|
||||
return a.storage, a.cfg.WebDAVPath, a.storage != nil
|
||||
}
|
||||
if !a.hasPermission(user.ID, PermWebDAV) {
|
||||
return nil, "", false
|
||||
}
|
||||
// Regular users use the system/global WebDAV only. They cannot override
|
||||
// the destination; privileged users may have their own WebDAV config.
|
||||
if user.Role == RoleUser {
|
||||
if a.cfg.WebDAVURL == "" || a.storage == nil {
|
||||
return nil, "", false
|
||||
}
|
||||
return a.storage, a.cfg.WebDAVPath, true
|
||||
}
|
||||
if user.Role == RoleAdmin {
|
||||
if a.cfg.WebDAVURL == "" || a.storage == nil {
|
||||
return nil, "", false
|
||||
}
|
||||
return a.storage, a.cfg.WebDAVPath, true
|
||||
}
|
||||
var cfg WebDAVConfig
|
||||
if a.db.Where("user_id = ? AND enabled = ?", user.ID, true).First(&cfg).Error != nil || cfg.URL == "" {
|
||||
return nil, "", false
|
||||
|
||||
Reference in New Issue
Block a user