feat: auth, site creation with PHP version selection

This commit is contained in:
orohi
2026-06-17 04:46:44 +03:00
parent 0f31c24bf9
commit b7753505b8
20 changed files with 1097 additions and 114 deletions
+15 -3
View File
@@ -6,6 +6,8 @@ import (
"fmt"
"github.com/panelhosting/panel/internal/auth"
"github.com/panelhosting/panel/internal/bootstrap"
"github.com/panelhosting/panel/internal/config"
"github.com/panelhosting/panel/internal/models"
"github.com/panelhosting/panel/internal/repository"
)
@@ -13,11 +15,13 @@ import (
var ErrSetupCompleted = errors.New("setup already completed")
type Service struct {
users *repository.UserRepository
users *repository.UserRepository
servers *repository.ServerRepository
cfg *config.Config
}
func NewService(users *repository.UserRepository) *Service {
return &Service{users: users}
func NewService(users *repository.UserRepository, servers *repository.ServerRepository, cfg *config.Config) *Service {
return &Service{users: users, servers: servers, cfg: cfg}
}
func (s *Service) Status(ctx context.Context) (bool, error) {
@@ -59,5 +63,13 @@ func (s *Service) RegisterFirstAdmin(ctx context.Context, in RegisterInput) (*mo
if err != nil {
return nil, fmt.Errorf("register admin: %w", err)
}
if err := bootstrap.EnsureDefaultServer(ctx, s.servers, s.cfg); err != nil {
return nil, fmt.Errorf("bootstrap server: %w", err)
}
if err := bootstrap.GrantServerAccess(ctx, s.servers, user.ID); err != nil {
return nil, fmt.Errorf("grant server access: %w", err)
}
return user, nil
}