Finish the basic share code validate.

This commit is contained in:
zicla
2019-05-01 03:05:33 +08:00
parent ebd20c6db5
commit adf4b9ea5a
4 changed files with 71 additions and 22 deletions

View File

@ -17,6 +17,7 @@ type AlienService struct {
userDao *UserDao
uploadTokenDao *UploadTokenDao
downloadTokenDao *DownloadTokenDao
shareService *ShareService
imageCacheDao *ImageCacheDao
imageCacheService *ImageCacheService
}
@ -51,6 +52,11 @@ func (this *AlienService) Init() {
this.downloadTokenDao = c
}
b = core.CONTEXT.GetBean(this.shareService)
if c, ok := b.(*ShareService); ok {
this.shareService = c
}
b = core.CONTEXT.GetBean(this.imageCacheDao)
if c, ok := b.(*ImageCacheDao); ok {
this.imageCacheDao = c
@ -105,8 +111,15 @@ func (this *AlienService) PreviewOrDownload(
//判断文件的所属人是否正确
operator := this.findUser(writer, request)
if operator == nil || (operator.Role != USER_ROLE_ADMINISTRATOR && matter.UserUuid != operator.Uuid) {
//可以使用分享码的形式授权。
shareUuid := request.FormValue("shareUuid")
shareCode := request.FormValue("shareCode")
shareRootUuid := request.FormValue("shareRootUuid")
if shareUuid == "" || shareCode == "" || shareRootUuid == "" {
panic(result.UNAUTHORIZED)
} else {
this.shareService.ValidateMatter(shareUuid, shareCode, operator, shareRootUuid, matter)
}
}