mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 10:19:27 +08:00
update admin creation for pocketbase 0.23.0
This commit is contained in:
@@ -1,16 +1,32 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/security"
|
||||
)
|
||||
|
||||
var (
|
||||
TempAdminEmail = "_@b.b"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
// initial settings
|
||||
settings := app.Settings()
|
||||
settings.Meta.AppName = "Beszel"
|
||||
settings.Meta.HideControls = true
|
||||
|
||||
return app.Save(settings)
|
||||
if err := app.Save(settings); err != nil {
|
||||
log.Println("failed to save settings", err)
|
||||
return err
|
||||
}
|
||||
// create superuser
|
||||
collection, _ := app.FindCollectionByNameOrId(core.CollectionNameSuperusers)
|
||||
user := core.NewRecord(collection)
|
||||
user.SetEmail(TempAdminEmail)
|
||||
user.SetPassword(security.RandomString(12))
|
||||
return app.Save(user)
|
||||
}, nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user