[#1030] fixed auth collection rules validator
This commit is contained in:
		
							parent
							
								
									9322b13d15
								
							
						
					
					
						commit
						f3566149b8
					
				|  | @ -279,8 +279,12 @@ func (form *CollectionUpsert) checkRule(value any) error { | ||||||
| 		return nil // nothing to check
 | 		return nil // nothing to check
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	dummy := &models.Collection{Schema: form.Schema} | 	dummy := *form.collection | ||||||
| 	r := resolvers.NewRecordFieldResolver(form.dao, dummy, nil, true) | 	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) | 	_, err := search.FilterData(*v).BuildExpr(r) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  |  | ||||||
|  | @ -279,11 +279,11 @@ func TestCollectionUpsertValidateAndSubmit(t *testing.T) { | ||||||
| 				"schema": [ | 				"schema": [ | ||||||
| 					{"id":"_2hlxbmp","name":"test","type":"text"} | 					{"id":"_2hlxbmp","name":"test","type":"text"} | ||||||
| 				], | 				], | ||||||
| 				"listRule": "test='123'", | 				"listRule": "test='123' && verified = true", | ||||||
| 				"viewRule": "test='123'", | 				"viewRule": "test='123' && emailVisibility = true", | ||||||
| 				"createRule": "test='123'", | 				"createRule": "test='123' && email != ''", | ||||||
| 				"updateRule": "test='123'", | 				"updateRule": "test='123' && username != ''", | ||||||
| 				"deleteRule": "test='123'", | 				"deleteRule": "test='123' && id != ''", | ||||||
| 				"options": {"minPasswordLength": 10} | 				"options": {"minPasswordLength": 10} | ||||||
| 			}`, | 			}`, | ||||||
| 			[]string{}, | 			[]string{}, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue