mirror of https://github.com/Xhofe/alist
feat(search): support with password
parent
6e23c8b4c0
commit
2dd30f2b77
|
@ -14,6 +14,11 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type SearchReq struct {
|
||||
model.SearchReq
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type SearchResp struct {
|
||||
model.SearchNode
|
||||
Type int `json:"type"`
|
||||
|
@ -21,7 +26,7 @@ type SearchResp struct {
|
|||
|
||||
func Search(c *gin.Context) {
|
||||
var (
|
||||
req model.SearchReq
|
||||
req SearchReq
|
||||
err error
|
||||
)
|
||||
if err = c.ShouldBind(&req); err != nil {
|
||||
|
@ -38,7 +43,7 @@ func Search(c *gin.Context) {
|
|||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
nodes, total, err := search.Search(c, req)
|
||||
nodes, total, err := search.Search(c, req.SearchReq)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
|
@ -52,7 +57,7 @@ func Search(c *gin.Context) {
|
|||
if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
||||
continue
|
||||
}
|
||||
if !common.CanAccess(user, meta, path.Join(node.Parent, node.Name), "") {
|
||||
if !common.CanAccess(user, meta, path.Join(node.Parent, node.Name), req.Password) {
|
||||
continue
|
||||
}
|
||||
filteredNodes = append(filteredNodes, node)
|
||||
|
|
Loading…
Reference in New Issue