users: remove unused username field and require email (#24)

This commit is contained in:
Henry Dollman
2025-02-03 18:29:02 -05:00
parent fdbbbc77b0
commit ff5eb07716
2 changed files with 98 additions and 4 deletions

View File

@@ -5,7 +5,6 @@ import (
"beszel/migrations"
"log"
"net/http"
"strings"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
@@ -98,9 +97,6 @@ func (um *UserManager) CreateFirstUser(e *core.RequestEvent) error {
user.SetPassword(data.Password)
user.Set("role", "admin")
user.Set("verified", true)
if username := strings.Split(data.Email, "@")[0]; len(username) > 2 {
user.Set("username", username)
}
if err := um.app.Save(user); err != nil {
return e.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
}