update default admin

This commit is contained in:
yoan 2024-08-26 21:51:51 +08:00
parent 4a03f930a1
commit c820fee906
2 changed files with 30 additions and 1 deletions

View File

@ -27,7 +27,7 @@ Certimate 旨在为用户提供一个安全、简便的 SSL 证书管理解决
默认账号:
```bash
用户名admin@essay.com
用户名admin@certimate.fun
密码1234567890
```

View File

@ -0,0 +1,29 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
// add up queries...
dao := daos.New(db)
admin := &models.Admin{}
admin.Email = "admin@certimate.fun"
admin.SetPassword("1234567890")
return dao.SaveAdmin(admin)
}, func(db dbx.Builder) error {
// add down queries...
dao := daos.New(db)
admin, _ := dao.FindAdminByEmail("admin@certimate.fun")
if admin != nil {
return dao.DeleteAdmin(admin)
}
return nil
})
}