From bbd0af3dd3ddce2c32ed6575288d4675394cf23a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 31 Dec 2020 12:02:26 +0100 Subject: [PATCH] Shares: Allow reuse of the same share slugs & tokens #776 --- internal/api/share.go | 2 +- internal/entity/link.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/share.go b/internal/api/share.go index 992c796de..536428b0c 100644 --- a/internal/api/share.go +++ b/internal/api/share.go @@ -39,7 +39,7 @@ func Shares(router *gin.RouterGroup) { links := entity.FindValidLinks(token, share) - if len(links) != 1 { + if len(links) < 1 { log.Warn("share: invalid token or share") c.Redirect(http.StatusTemporaryRedirect, "/") return diff --git a/internal/entity/link.go b/internal/entity/link.go index 100fb5bcc..03318f4a3 100644 --- a/internal/entity/link.go +++ b/internal/entity/link.go @@ -168,7 +168,7 @@ func FindLinks(token, share string) (result Links) { } } - if err := q.Find(&result).Error; err != nil { + if err := q.Order("modified_at DESC").Find(&result).Error; err != nil { log.Errorf("link: %s (not found)", err) }