mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-11-01 10:36:30 +08:00
Feat: list files for shared folder
This commit is contained in:
@ -49,6 +49,30 @@ func ShareCanPreview() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// CheckShareUnlocked 检查分享是否已解锁
|
||||
func CheckShareUnlocked() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if shareCtx, ok := c.Get("share"); ok {
|
||||
share := shareCtx.(*model.Share)
|
||||
// 分享是否已解锁
|
||||
if share.Password != "" {
|
||||
sessionKey := fmt.Sprintf("share_unlock_%d", share.ID)
|
||||
unlocked := util.GetSession(c, sessionKey) != nil
|
||||
if !unlocked {
|
||||
c.JSON(200, serializer.Err(serializer.CodeNoPermissionErr,
|
||||
"无权访问此分享", nil))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
c.Abort()
|
||||
}
|
||||
}
|
||||
|
||||
// BeforeShareDownload 分享被下载前的检查
|
||||
func BeforeShareDownload() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
@ -66,18 +90,6 @@ func BeforeShareDownload() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// 分享是否已解锁
|
||||
if share.Password != "" {
|
||||
sessionKey := fmt.Sprintf("share_unlock_%d", share.ID)
|
||||
unlocked := util.GetSession(c, sessionKey) != nil
|
||||
if !unlocked {
|
||||
c.JSON(200, serializer.Err(serializer.CodeNoPermissionErr,
|
||||
"无权访问此分享", nil))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 对积分、下载次数进行更新
|
||||
err = share.DownloadBy(user, c)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user