wip: boarding
This commit is contained in:
@@ -66,8 +66,6 @@ function get_private_key_for_server(Server $server)
|
||||
function save_private_key_for_server(Server $server)
|
||||
{
|
||||
if (data_get($server, 'privateKey.private_key') === null) {
|
||||
$server->settings->is_reachable = false;
|
||||
$server->settings->save();
|
||||
throw new \Exception("Server {$server->name} does not have a private key");
|
||||
}
|
||||
$temp_file = "id.root@{$server->ip}";
|
||||
@@ -159,8 +157,8 @@ function refresh_server_connection(PrivateKey $private_key)
|
||||
// Delete the old ssh mux file to force a new one to be created
|
||||
Storage::disk('ssh-mux')->delete($server->muxFilename());
|
||||
// check if user is authenticated
|
||||
if (auth()?->user()?->currentTeam()->id) {
|
||||
auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get();
|
||||
if (currentTeam()->id) {
|
||||
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use Illuminate\Support\Str;
|
||||
use Nubs\RandomNameGenerator\All;
|
||||
use Poliander\Cron\CronExpression;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
use phpseclib3\Crypt\RSA;
|
||||
|
||||
function application_configuration_dir(): string
|
||||
{
|
||||
@@ -35,11 +36,25 @@ function generate_readme_file(string $name, string $updated_at): string
|
||||
return "Resource name: $name\nLatest Deployment Date: $updated_at";
|
||||
}
|
||||
|
||||
function is_instance_admin()
|
||||
function isInstanceAdmin()
|
||||
{
|
||||
return auth()->user()?->isInstanceAdmin();
|
||||
return auth()?->user()?->isInstanceAdmin() ?? false;
|
||||
}
|
||||
|
||||
function currentTeam()
|
||||
{
|
||||
return auth()?->user()?->currentTeam() ?? null;
|
||||
}
|
||||
|
||||
function showBoarding(): bool
|
||||
{
|
||||
return currentTeam()->show_boarding ?? false;
|
||||
}
|
||||
function refreshSession(): void
|
||||
{
|
||||
$team = currentTeam();
|
||||
session(['currentTeam' => $team]);
|
||||
}
|
||||
function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed
|
||||
{
|
||||
try {
|
||||
@@ -97,7 +112,21 @@ function generate_random_name(): string
|
||||
$cuid = new Cuid2(7);
|
||||
return Str::kebab("{$generator->getName()}-$cuid");
|
||||
}
|
||||
|
||||
function generateSSHKey()
|
||||
{
|
||||
$key = RSA::createKey();
|
||||
return [
|
||||
'private' => $key->toString('PKCS1'),
|
||||
'public' => $key->getPublicKey()->toString('OpenSSH',['comment' => 'coolify-generated-ssh-key'])
|
||||
];
|
||||
}
|
||||
function formatPrivateKey(string $privateKey) {
|
||||
$privateKey = trim($privateKey);
|
||||
if (!str_ends_with($privateKey, "\n")) {
|
||||
$privateKey .= "\n";
|
||||
}
|
||||
return $privateKey;
|
||||
}
|
||||
function generate_application_name(string $git_repository, string $git_branch): string
|
||||
{
|
||||
$cuid = new Cuid2(7);
|
||||
|
||||
@@ -9,7 +9,7 @@ function getSubscriptionLink($type)
|
||||
return null;
|
||||
}
|
||||
$user_id = auth()->user()->id;
|
||||
$team_id = auth()->user()->currentTeam()->id ?? null;
|
||||
$team_id = currentTeam()->id ?? null;
|
||||
$email = auth()->user()->email ?? null;
|
||||
$name = auth()->user()->name ?? null;
|
||||
$url = "https://store.coollabs.io/checkout/buy/$checkout_id?";
|
||||
@@ -30,27 +30,27 @@ function getSubscriptionLink($type)
|
||||
|
||||
function getPaymentLink()
|
||||
{
|
||||
return auth()->user()->currentTeam()->subscription->lemon_update_payment_menthod_url;
|
||||
return currentTeam()->subscription->lemon_update_payment_menthod_url;
|
||||
}
|
||||
|
||||
function getRenewDate()
|
||||
{
|
||||
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
}
|
||||
|
||||
function getEndDate()
|
||||
{
|
||||
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
}
|
||||
|
||||
function is_subscription_active()
|
||||
{
|
||||
$team = auth()->user()?->currentTeam();
|
||||
$team = currentTeam();
|
||||
|
||||
if (!$team) {
|
||||
return false;
|
||||
}
|
||||
if (is_instance_admin()) {
|
||||
if (isInstanceAdmin()) {
|
||||
return true;
|
||||
}
|
||||
$subscription = $team?->subscription;
|
||||
@@ -64,11 +64,11 @@ function is_subscription_active()
|
||||
}
|
||||
function is_subscription_in_grace_period()
|
||||
{
|
||||
$team = auth()->user()?->currentTeam();
|
||||
$team = currentTeam();
|
||||
if (!$team) {
|
||||
return false;
|
||||
}
|
||||
if (is_instance_admin()) {
|
||||
if (isInstanceAdmin()) {
|
||||
return true;
|
||||
}
|
||||
$subscription = $team?->subscription;
|
||||
|
||||
Reference in New Issue
Block a user