From 4528f075dc776c90abeec67b7380ce0d01f4ad42 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Tue, 15 Nov 2022 15:06:46 +0200 Subject: [PATCH] fixed auth collection rule check validator on create --- forms/collection_upsert.go | 1 + forms/collection_upsert_test.go | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/forms/collection_upsert.go b/forms/collection_upsert.go index 576db38a6..3b0aae4bc 100644 --- a/forms/collection_upsert.go +++ b/forms/collection_upsert.go @@ -280,6 +280,7 @@ func (form *CollectionUpsert) checkRule(value any) error { } dummy := *form.collection + dummy.Type = form.Type dummy.Schema = form.Schema dummy.System = form.System dummy.Options = form.Options diff --git a/forms/collection_upsert_test.go b/forms/collection_upsert_test.go index 1f510a8f0..5be059fd5 100644 --- a/forms/collection_upsert_test.go +++ b/forms/collection_upsert_test.go @@ -185,16 +185,17 @@ func TestCollectionUpsertValidateAndSubmit(t *testing.T) { "", `{ "name": "test_new", + "type": "auth", "system": true, "schema": [ {"id":"a123456","name":"test1","type":"text"}, {"id":"b123456","name":"test2","type":"email"} ], - "listRule": "test1='123'", - "viewRule": "test1='123'", - "createRule": "test1='123'", - "updateRule": "test1='123'", - "deleteRule": "test1='123'" + "listRule": "test1='123' && verified = true", + "viewRule": "test1='123' && emailVisibility = true", + "createRule": "test1='123' && email != ''", + "updateRule": "test1='123' && username != ''", + "deleteRule": "test1='123' && id != ''" }`, []string{}, },