fix: hide check in canAccess
(#2556)
修复 meta.Password 和 meta.Hide 都为空的情况下,会导致无权限访问
This commit is contained in:
parent
09f480318c
commit
ae791c8634
@ -17,7 +17,7 @@ func CanWrite(meta *model.Meta, path string) bool {
|
|||||||
|
|
||||||
func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool {
|
func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool {
|
||||||
// if the reqPath is in hide (only can check the nearest meta) and user can't see hides, can't access
|
// if the reqPath is in hide (only can check the nearest meta) and user can't see hides, can't access
|
||||||
if meta != nil && !user.CanSeeHides() {
|
if meta != nil && !user.CanSeeHides() && meta.Hide != "" {
|
||||||
for _, hide := range strings.Split(meta.Hide, "\n") {
|
for _, hide := range strings.Split(meta.Hide, "\n") {
|
||||||
re := regexp.MustCompile(hide)
|
re := regexp.MustCompile(hide)
|
||||||
if re.MatchString(reqPath[len(meta.Path):]) {
|
if re.MatchString(reqPath[len(meta.Path):]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user