mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
feat(webdav): add read-only option (#1629)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/webdav"
|
||||
"github.com/cloudreve/Cloudreve/v3/service/setting"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -39,6 +40,15 @@ func ServeWebDAV(c *gin.Context) {
|
||||
fs.Root = root
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否只读
|
||||
if application.Readonly {
|
||||
switch c.Request.Method {
|
||||
case "DELETE", "PUT", "MKCOL", "COPY", "MOVE":
|
||||
c.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler.ServeHTTP(c.Writer, c.Request, fs)
|
||||
@@ -66,6 +76,17 @@ func DeleteWebDAVAccounts(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateWebDAVAccountsReadonly 更改WebDAV账户只读性
|
||||
func UpdateWebDAVAccountsReadonly(c *gin.Context) {
|
||||
var service setting.WebDAVAccountUpdateReadonlyService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Update(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// CreateWebDAVAccounts 创建WebDAV账户
|
||||
func CreateWebDAVAccounts(c *gin.Context) {
|
||||
var service setting.WebDAVAccountCreateService
|
||||
|
||||
Reference in New Issue
Block a user