hub: return error if accessing /api/beszel/universal-token with a superuser account (#1870)

This commit is contained in:
henrygd
2026-04-01 22:16:47 -04:00
parent ba10da1b9f
commit 0fff699bf6
3 changed files with 33 additions and 0 deletions

View File

@@ -77,6 +77,16 @@ func CreateUser(app core.App, email string, password string) (*core.Record, erro
return user, app.Save(user)
}
// Helper function to create a test superuser for config tests
func CreateSuperuser(app core.App, email string, password string) (*core.Record, error) {
superusersCollection, _ := app.FindCachedCollectionByNameOrId(core.CollectionNameSuperusers)
superuser := core.NewRecord(superusersCollection)
superuser.Set("email", email)
superuser.Set("password", password)
return superuser, app.Save(superuser)
}
func CreateUserWithRole(app core.App, email string, password string, roleName string) (*core.Record, error) {
user, err := CreateUser(app, email, password)
if err != nil {