feat: auth, site creation with PHP version selection
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/panelhosting/panel/internal/config"
|
||||
"github.com/panelhosting/panel/internal/repository"
|
||||
)
|
||||
|
||||
func EnsureDefaultServer(ctx context.Context, servers *repository.ServerRepository, cfg *config.Config) error {
|
||||
count, err := servers.Count(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return nil
|
||||
}
|
||||
_, err = servers.CreateDefault(ctx, cfg.DefaultServerName, cfg.DefaultServerHost, cfg.DefaultServerIP)
|
||||
return err
|
||||
}
|
||||
|
||||
func GrantServerAccess(ctx context.Context, servers *repository.ServerRepository, userID int64) error {
|
||||
srv, err := servers.GetFirst(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return servers.GrantAccess(ctx, userID, srv.ID, true)
|
||||
}
|
||||
Reference in New Issue
Block a user