Files
OpenList/server/middlewares/down.go

20 lines
423 B
Go
Raw Normal View History

2021-12-07 15:56:43 +08:00
package middlewares
import (
"fmt"
"github.com/Xhofe/alist/server/common"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
)
func DownCheck(c *gin.Context) {
rawPath := c.Param("path")
rawPath = utils.ParsePath(rawPath)
pw := c.Query("pw")
if !common.CheckDownLink(utils.Dir(rawPath), pw, utils.Base(rawPath)) {
common.ErrorResp(c, fmt.Errorf("wrong password"), 401)
c.Abort()
return
}
c.Next()
}