fix(collections): add authentication check to PreviewCollection handler

The PreviewCollection endpoint was missing authentication verification,
allowing unauthenticated access to the preview functionality. Added
check for user in context, returning 401 Unauthorized if missing.
This commit is contained in:
2026-02-20 17:04:02 -05:00
parent 542fbea313
commit 33fcc416b9
+5
View File
@@ -827,6 +827,11 @@ func (h *CollectionHandler) HandleBulkAddBooks(c echo.Context) error {
} }
func (h *CollectionHandler) PreviewCollection(c echo.Context) error { func (h *CollectionHandler) PreviewCollection(c echo.Context) error {
user := c.Get("user")
if user == nil {
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "unauthorized"})
}
var req struct { var req struct {
LibraryID string `json:"library_id"` LibraryID string `json:"library_id"`
Rules []services.Rule `json:"rules"` Rules []services.Rule `json:"rules"`