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"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type SearchReq struct {
|
||||||
|
model.SearchReq
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
|
|
||||||
type SearchResp struct {
|
type SearchResp struct {
|
||||||
model.SearchNode
|
model.SearchNode
|
||||||
Type int `json:"type"`
|
Type int `json:"type"`
|
||||||
|
@ -21,7 +26,7 @@ type SearchResp struct {
|
||||||
|
|
||||||
func Search(c *gin.Context) {
|
func Search(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req model.SearchReq
|
req SearchReq
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if err = c.ShouldBind(&req); err != nil {
|
if err = c.ShouldBind(&req); err != nil {
|
||||||
|
@ -38,7 +43,7 @@ func Search(c *gin.Context) {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nodes, total, err := search.Search(c, req)
|
nodes, total, err := search.Search(c, req.SearchReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
|
@ -52,7 +57,7 @@ func Search(c *gin.Context) {
|
||||||
if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
||||||
continue
|
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
|
continue
|
||||||
}
|
}
|
||||||
filteredNodes = append(filteredNodes, node)
|
filteredNodes = append(filteredNodes, node)
|
||||||
|
|
Loading…
Reference in New Issue