Skip to content

Commit

Permalink
[pocketbase#1030] fixed auth collection rules validator
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Nov 15, 2022
1 parent 9322b13 commit f356614
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions forms/collection_upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,12 @@ func (form *CollectionUpsert) checkRule(value any) error {
return nil // nothing to check
}

dummy := &models.Collection{Schema: form.Schema}
r := resolvers.NewRecordFieldResolver(form.dao, dummy, nil, true)
dummy := *form.collection
dummy.Schema = form.Schema
dummy.System = form.System
dummy.Options = form.Options

r := resolvers.NewRecordFieldResolver(form.dao, &dummy, nil, true)

_, err := search.FilterData(*v).BuildExpr(r)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions forms/collection_upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ func TestCollectionUpsertValidateAndSubmit(t *testing.T) {
"schema": [
{"id":"_2hlxbmp","name":"test","type":"text"}
],
"listRule": "test='123'",
"viewRule": "test='123'",
"createRule": "test='123'",
"updateRule": "test='123'",
"deleteRule": "test='123'",
"listRule": "test='123' && verified = true",
"viewRule": "test='123' && emailVisibility = true",
"createRule": "test='123' && email != ''",
"updateRule": "test='123' && username != ''",
"deleteRule": "test='123' && id != ''",
"options": {"minPasswordLength": 10}
}`,
[]string{},
Expand Down

0 comments on commit f356614

Please sign in to comment.