feat: auth, site creation with PHP version selection
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user