package migrations import ( "github.com/pocketbase/pocketbase/core" ) const oldAuthAlertTemplate = `

Hello,

We noticed a login to your ` + core.EmailPlaceholderAppName + ` account from a new location.

If this was you, you may disregard this email.

If this wasn't you, you should immediately change your ` + core.EmailPlaceholderAppName + ` account password to revoke access from all other locations.

Thanks,
` + core.EmailPlaceholderAppName + ` team

` func init() { core.SystemMigrations.Register(func(txApp core.App) error { collections, err := txApp.FindAllCollections(core.CollectionTypeAuth) if err != nil { return err } newTemplate := core.NewAuthCollection("up").AuthAlert.EmailTemplate.Body for _, c := range collections { if c.AuthAlert.EmailTemplate.Body != oldAuthAlertTemplate { continue } c.AuthAlert.EmailTemplate.Body = newTemplate err = txApp.Save(c) if err != nil { return err } } return nil }, func(txApp core.App) error { collections, err := txApp.FindAllCollections(core.CollectionTypeAuth) if err != nil { return err } newTemplate := core.NewAuthCollection("down").AuthAlert.EmailTemplate.Body for _, c := range collections { if c.AuthAlert.EmailTemplate.Body != newTemplate { continue } c.AuthAlert.EmailTemplate.Body = oldAuthAlertTemplate err = txApp.Save(c) if err != nil { return err } } return nil }) }