fix: give regular users global webdav access

This commit is contained in:
OpenClaw Agent
2026-09-17 03:11:55 +08:00
parent 7169a7b5fd
commit 44a365822b
2 changed files with 15 additions and 7 deletions
+14 -6
View File
@@ -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