2022-09-28 09:01:17 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
2022-10-13 22:11:02 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
2022-09-28 09:01:17 +02:00
|
|
|
"github.com/photoprism/photoprism/pkg/clean"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InvalidPreviewToken checks if the token found in the request is valid for image thumbnails and video streams.
|
|
|
|
func InvalidPreviewToken(c *gin.Context) bool {
|
|
|
|
token := clean.UrlToken(c.Param("token"))
|
|
|
|
|
|
|
|
if token == "" {
|
|
|
|
token = clean.UrlToken(c.Query("t"))
|
|
|
|
}
|
|
|
|
|
2022-10-13 22:11:02 +02:00
|
|
|
return entity.InvalidPreviewToken(token)
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidDownloadToken checks if the token found in the request is valid for file downloads.
|
|
|
|
func InvalidDownloadToken(c *gin.Context) bool {
|
2022-10-13 22:11:02 +02:00
|
|
|
return entity.InvalidDownloadToken(clean.UrlToken(c.Query("t")))
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|