From 4ca8bc06d8e8572f8b1e1123fe9e51f79aa424fc Mon Sep 17 00:00:00 2001 From: lishuang Date: Sat, 8 Jul 2023 15:25:39 +0800 Subject: [PATCH] fix: refine the share's things. --- code/rest/share_controller.go | 4 ++-- code/rest/share_service.go | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/code/rest/share_controller.go b/code/rest/share_controller.go index e0838e9..2197c61 100644 --- a/code/rest/share_controller.go +++ b/code/rest/share_controller.go @@ -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) diff --git a/code/rest/share_service.go b/code/rest/share_service.go index e2c990d..5050e35 100644 --- a/code/rest/share_service.go +++ b/code/rest/share_service.go @@ -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.