🔒 not allowed delete root folder

This commit is contained in:
微凉
2022-01-13 21:23:27 +08:00
parent 65a01251e9
commit b472c2ee18
9 changed files with 27 additions and 19 deletions

View File

@ -1,7 +1,6 @@
package middlewares
import (
"fmt"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/model"
"github.com/Xhofe/alist/server/common"
@ -25,13 +24,13 @@ func PathCheck(c *gin.Context) {
meta, err := model.GetMetaByPath(req.Path)
if err == nil {
if meta.Password != "" && meta.Password != req.Password {
common.ErrorResp(c, fmt.Errorf("wrong password"), 401)
common.ErrorStrResp(c, "Wrong password", 401)
c.Abort()
return
}
} else if conf.GetBool("check parent folder") {
if !common.CheckParent(utils.Dir(req.Path), req.Password) {
common.ErrorResp(c, fmt.Errorf("wrong password"), 401)
common.ErrorStrResp(c, "Wrong password", 401)
c.Abort()
return
}