From 650f57f2af903bed5b87140b4480ed88fa5b1343 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 26 Sep 2020 13:43:32 +0200 Subject: [PATCH] Fix updating saved filters --- pkg/db/test.go | 2 +- pkg/models/saved_filters_rights.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/db/test.go b/pkg/db/test.go index b0bb980f2..719ddd435 100644 --- a/pkg/db/test.go +++ b/pkg/db/test.go @@ -78,7 +78,7 @@ func AssertDBExists(t *testing.T, table string, values map[string]interface{}, c var exists bool var err error v := make(map[string]interface{}) - // Postgres sometimes needs to build raw sql. Because is won't always need to do this and this isn't fun, it's a flag. + // Postgres sometimes needs to build raw sql. Because it won't always need to do this and this isn't fun, it's a flag. if custom { //#nosec sql := "SELECT * FROM " + table + " WHERE " diff --git a/pkg/models/saved_filters_rights.go b/pkg/models/saved_filters_rights.go index ee499f79a..2e869fe8d 100644 --- a/pkg/models/saved_filters_rights.go +++ b/pkg/models/saved_filters_rights.go @@ -31,7 +31,9 @@ func (s *SavedFilter) CanDelete(auth web.Auth) (bool, error) { // CanUpdate checks if a user has the right to update a saved filter func (s *SavedFilter) CanUpdate(auth web.Auth) (bool, error) { - return s.canDoFilter(auth) + // A normal check would replace the passed struct which in our case would override the values we want to update. + sf := &SavedFilter{ID: s.ID} + return sf.canDoFilter(auth) } // CanCreate checks if a user has the right to update a saved filter