fix: refine the share's things.

This commit is contained in:
lishuang
2023-07-08 15:25:39 +08:00
parent 76d4752776
commit 4ca8bc06d8
2 changed files with 5 additions and 8 deletions
+2 -2
View File
@@ -394,7 +394,7 @@ func (this *ShareController) MatterPage(writer http.ResponseWriter, request *htt
//validate the shareUuid,shareCode,shareRootUuid.
user := this.findUser(request)
this.shareService.ValidateMatter(request, shareUuid, shareCode, user, shareRootUuid, dirMatter)
share := this.shareService.ValidateMatter(request, shareUuid, shareCode, user, shareRootUuid, dirMatter)
puuid = dirMatter.Uuid
var extensions []string
@@ -419,7 +419,7 @@ func (this *ShareController) MatterPage(writer http.ResponseWriter, request *htt
dir,
deleted,
extensions,
dirMatter.SpaceUuid,
share.SpaceUuid,
)
return this.Success(pager)
+3 -6
View File
@@ -75,17 +75,12 @@ func (this *ShareService) CheckShare(request *http.Request, shareUuid string, co
}
// check whether a user can access a matter. shareRootUuid is matter's parent(or parent's parent and so on)
func (this *ShareService) ValidateMatter(request *http.Request, shareUuid string, code string, user *User, shareRootUuid string, matter *Matter) {
func (this *ShareService) ValidateMatter(request *http.Request, shareUuid string, code string, user *User, shareRootUuid string, matter *Matter) *Share {
if matter == nil {
panic(result.Unauthorized("matter cannot be nil"))
}
//if self's matter, ok.
if user != nil && matter.UserUuid == user.Uuid {
return
}
if shareUuid == "" || code == "" || shareRootUuid == "" {
panic(result.Unauthorized("shareUuid,code,shareRootUuid cannot be null"))
}
@@ -114,6 +109,8 @@ func (this *ShareService) ValidateMatter(request *http.Request, shareUuid string
}
}
return share
}
// delete user's shares and corresponding bridges.