lock the _mfas and _otps delete api rule, fixed flaky tests, fixed jsvm types example
This commit is contained in:
@@ -51,6 +51,8 @@ func init() {
|
||||
[[created]] TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%fZ')) NOT NULL,
|
||||
[[updated]] TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%fZ')) NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx__collections_type on {{_collections}} ([[type]]);
|
||||
`).Execute()
|
||||
if execerr != nil {
|
||||
return fmt.Errorf("_collections exec error: %w", execerr)
|
||||
@@ -122,7 +124,6 @@ func createMFAsCollection(txApp core.App) error {
|
||||
ownerRule := "@request.auth.id != '' && recordRef = @request.auth.id && collectionRef = @request.auth.collectionId"
|
||||
col.ListRule = types.Pointer(ownerRule)
|
||||
col.ViewRule = types.Pointer(ownerRule)
|
||||
col.DeleteRule = types.Pointer(ownerRule)
|
||||
|
||||
col.Fields.Add(&core.TextField{
|
||||
Name: "collectionRef",
|
||||
@@ -162,7 +163,6 @@ func createOTPsCollection(txApp core.App) error {
|
||||
ownerRule := "@request.auth.id != '' && recordRef = @request.auth.id && collectionRef = @request.auth.collectionId"
|
||||
col.ListRule = types.Pointer(ownerRule)
|
||||
col.ViewRule = types.Pointer(ownerRule)
|
||||
col.DeleteRule = types.Pointer(ownerRule)
|
||||
|
||||
col.Fields.Add(&core.TextField{
|
||||
Name: "collectionRef",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
// note: this migration will be deleted in future version
|
||||
|
||||
func init() {
|
||||
core.SystemMigrations.Register(func(txApp core.App) error {
|
||||
_, err := txApp.DB().NewQuery("CREATE INDEX IF NOT EXISTS idx__collections_type on {{_collections}} ([[type]]);").Execute()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// reset mfas and otps delete rule
|
||||
collectionNames := []string{core.CollectionNameMFAs, core.CollectionNameOTPs}
|
||||
for _, name := range collectionNames {
|
||||
col, err := txApp.FindCollectionByNameOrId(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if col.DeleteRule != nil {
|
||||
col.DeleteRule = nil
|
||||
err = txApp.SaveNoValidate(col)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user