An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
wip
Andras Bacsaicbefbb792729
diff --git a/app/Actions/License/CheckResaleLicense.php b/app/Actions/License/CheckResaleLicense.phpnew file mode 100644index 0000000000..9aa6e84861--- /dev/null+++ b/app/Actions/License/CheckResaleLicense.php@@ -0,0 +1,64 @@+<?php++namespace App\Actions\License;++use App\Models\InstanceSettings;+use Illuminate\Support\Facades\Http;+use Visus\Cuid2\Cuid2;++class CheckResaleLicense+{+ public function __invoke()+ {+ try {+ $settings = InstanceSettings::get();+ $instance_id = config('app.id');+ if (!$settings->resale_license) {+ return;+ }+ ray('Checking license key');+ $data = Http::withHeaders([+ 'Accept' => 'application/json',+ ])->post('https://api.lemonsqueezy.com/v1/licenses/validate', [+ 'license_key' => $settings->resale_license,+ 'instance_name' => $instance_id,+ ])->throw()->json();+ $product_id = data_get($data, 'meta.product_id');++ if (isDev()) {+ $valid_product_id = 93221;+ } else {+ $valid_product_id = 93222;+ }+ if ($product_id !== $valid_product_id) {+ throw new \Exception('Invalid product id');+ }+ ray('Valid Product Id');++ ['valid' => $valid, 'license_key' => $license_key] = $data;++ if ($valid) {+ if (data_get($license_key, 'status') === 'inactive') {+ Http::withHeaders([+ 'Accept' => 'application/json',+ ])->post('https://api.lemonsqueezy.com/v1/licenses/activate', [+ 'license_key' => $settings->resale_license,+ 'instance_name' => $instance_id,+ ])->throw()->json();+ }+ $settings->update([+ 'is_resale_license_active' => true,+ ]);+ return;+ }+ throw new \Exception('Invalid license key');+ } catch (\Throwable $th) {+ ray($th);+ $settings->update([+ 'resale_license' => null,+ 'is_resale_license_active' => false,+ ]);+ throw $th;+ }+ }+}diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex cbd91f662b..c35dc152fe 100644--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -2,9 +2,11 @@namespace App\Console;+use App\Jobs\CheckResaleLicenseJob;use App\Jobs\InstanceAutoUpdateJob;use App\Jobs\ProxyCheckJob;use App\Jobs\DockerCleanupJob;+use App\Jobs\CheckResaleLicenseKeys;use Illuminate\Console\Scheduling\Schedule;use Illuminate\Foundation\Console\Kernel as ConsoleKernel;@@ -14,6 +16,7 @@ class Kernel extends ConsoleKernel{if (isDev()) {$schedule->command('horizon:snapshot')->everyMinute();+ $schedule->job(new CheckResaleLicenseJob)->everyMinute();$schedule->job(new DockerCleanupJob)->everyOddHour();// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();} else {@@ -29,4 +32,4 @@ class Kernel extends ConsoleKernelrequire base_path('routes/console.php');}-}\ No newline at end of file+}diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 96cd1774df..98faaad2eb 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -17,9 +17,11 @@ class Controller extends BaseController{use AuthorizesRequests, ValidatesRequests;- public function license()+ public function subscription(){- return view('license');+ return view('subscription', [+ 'settings' => InstanceSettings::get()+ ]);}public function dashboard(){diff --git a/app/Http/Kernel.php b/app/Http/Kernel.phpindex 2080e9cca9..06777812fb 100644--- a/app/Http/Kernel.php+++ b/app/Http/Kernel.php@@ -21,7 +21,6 @@ class Kernel extends HttpKernel\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,\App\Http\Middleware\TrimStrings::class,\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,- \App\Http\Middleware\LicenseValid::class,];diff --git a/app/Http/Livewire/CheckLicense.php b/app/Http/Livewire/CheckLicense.phpnew file mode 100644index 0000000000..59942c6a63--- /dev/null+++ b/app/Http/Livewire/CheckLicense.php@@ -0,0 +1,42 @@+<?php++namespace App\Http\Livewire;++use App\Actions\License\CheckResaleLicense;+use App\Models\InstanceSettings;+use Livewire\Component;++class CheckLicense extends Component+{+ public InstanceSettings|null $settings = null;+ public string|null $instance_id = null;+ protected $rules = [+ 'settings.resale_license' => 'nullable',+ 'settings.is_resale_license_active' => 'nullable',+ ];+ protected $validationAttributes = [+ 'settings.resale_license' => 'License',+ 'instance_id' => 'Instance Id (Do not change this)',+ 'settings.is_resale_license_active' => 'Is License Active',+ ];+ public function mount()+ {+ $this->instance_id = config('app.id');+ $this->settings = InstanceSettings::get();+ }+ public function submit()+ {+ $this->validate();+ $this->settings->save();+ if ($this->settings->resale_license) {+ try {+ resolve(CheckResaleLicense::class)();+ $this->emit('reloadWindow');+ } catch (\Throwable $th) {+ session()->flash('error', 'License is not valid. Please contact support.');+ ray($th->getMessage());+ return redirect()->to('/subscription');+ }+ }+ }+}diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.phpindex 41eae45fd6..889e720096 100644--- a/app/Http/Livewire/Settings/Configuration.php+++ b/app/Http/Livewire/Settings/Configuration.php@@ -5,6 +5,7 @@ namespace App\Http\Livewire\Settings;use App\Jobs\ProxyCheckJob;use App\Models\InstanceSettings as ModelsInstanceSettings;use App\Models\Server;+use Illuminate\Support\Facades\Http;use Livewire\Component;use Spatie\Url\Url;use Symfony\Component\Yaml\Yaml;@@ -21,11 +22,13 @@ class Configuration extends Componentprotected $rules = ['settings.fqdn' => 'nullable',+ 'settings.resale_license' => 'nullable','settings.public_port_min' => 'required','settings.public_port_max' => 'required',];protected $validationAttributes = ['settings.fqdn' => 'FQDN',+ 'settings.resale_license' => 'Resale License','settings.public_port_min' => 'Public port min','settings.public_port_max' => 'Public port max',];diff --git a/app/Http/Middleware/LicenseValid.php b/app/Http/Middleware/LicenseValid.phpindex bc5fb53e56..52d5840e7e 100644--- a/app/Http/Middleware/LicenseValid.php+++ b/app/Http/Middleware/LicenseValid.php@@ -16,15 +16,21 @@ class LicenseValid*/public function handle(Request $request, Closure $next): Response{- if (isCloud() && !isDev()) {+ if (isCloud()) {$value = Cache::get('license_key');+ if (isDev()) {+ $value = true;+ }if (!$value) {- ray($request->path());if ($request->path() !== 'license' && $request->path() !== 'livewire/message/license') {return redirect('license');}+ } else {+ if ($request->path() === 'license' || $request->path() === 'livewire/message/license') {+ return redirect('home');+ }}}return $next($request);}-}\ No newline at end of file+}diff --git a/app/Http/Middleware/SubscriptionValid.php b/app/Http/Middleware/SubscriptionValid.phpindex c1ce35dbd1..ab2d9eb1f3 100644--- a/app/Http/Middleware/SubscriptionValid.php+++ b/app/Http/Middleware/SubscriptionValid.php@@ -4,33 +4,34 @@ namespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;-use Illuminate\Support\Facades\Cache;use Symfony\Component\HttpFoundation\Response;class SubscriptionValid{- /**- * Handle an incoming request.- *- * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next- */+public function handle(Request $request, Closure $next): Response{$allowed_paths = [- 'team',- 'livewire/message/team',+ 'subscription','login','register',- 'livewire/message/switch-team','logout',+ 'livewire/message/check-license',+ 'livewire/message/switch-team',];- if (isCloud()) {- if (!$request->user()?->currentTeam()?->subscription && $request->user()?->currentTeam()->subscription?->lemon_status !== 'active') {+ if (isCloud() && !isSubscribed()) {+ ray('SubscriptionValid Middleware');if (!in_array($request->path(), $allowed_paths)) {- return redirect('team');+ return redirect('subscription');+ } else {+ return $next($request);}+ } else {+ if ($request->path() === 'subscription') {+ return redirect('/');+ } else {+ return $next($request);}}- return $next($request);}-}\ No newline at end of file+}diff --git a/app/Jobs/CheckResaleLicenseJob.php b/app/Jobs/CheckResaleLicenseJob.phpnew file mode 100644index 0000000000..0e925c5690--- /dev/null+++ b/app/Jobs/CheckResaleLicenseJob.php@@ -0,0 +1,32 @@+<?php++namespace App\Jobs;++use App\Actions\License\CheckResaleLicense;+use App\Models\InstanceSettings;+use Illuminate\Bus\Queueable;+use Illuminate\Contracts\Queue\ShouldBeUnique;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Foundation\Bus\Dispatchable;+use Illuminate\Queue\InteractsWithQueue;+use Illuminate\Queue\SerializesModels;+use Illuminate\Support\Facades\Http;+use Visus\Cuid2\Cuid2;++class CheckResaleLicenseJob implements ShouldQueue+{+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;++ public function __construct()+ {+ }++ public function handle(): void+ {+ try {+ resolve(CheckResaleLicense::class)();+ } catch (\Throwable $th) {+ ray($th);+ }+ }+}diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.phpindex fefd315ce5..5f0cc8c004 100644--- a/app/Models/InstanceSettings.php+++ b/app/Models/InstanceSettings.php@@ -12,6 +12,7 @@ use Spatie\SchemalessAttributes\SchemalessAttributesTrait;class InstanceSettings extends Model implements SendsEmail{use Notifiable, SchemalessAttributesTrait;+ protected $guarded = [];protected $schemalessAttributes = ['smtp',];diff --git a/app/Models/User.php b/app/Models/User.phpindex aa08ad22be..13753a210e 100644--- a/app/Models/User.php+++ b/app/Models/User.php@@ -61,7 +61,8 @@ class User extends Authenticatable implements SendsEmail{return $this->email;}- public function isAdmin() {+ public function isAdmin()+ {return $this->pivot->role === 'admin' || $this->pivot->role === 'owner';}public function isAdminFromSession()@@ -91,7 +92,8 @@ class User extends Authenticatable implements SendsEmail});return $found_root_team->count() > 0;}- public function personalTeam() {+ public function personalTeam()+ {return $this->teams()->where('personal_team', true)->first();}public function teams()diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 3fd5b18332..f458256862 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -130,5 +130,5 @@ function isDev()}function isCloud(){- return !config('coolify.self_hosted');-}\ No newline at end of file+ return (bool)config('coolify.self_hosted') === false;+}diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.phpindex af4fc2131f..319212fd4a 100644--- a/bootstrap/helpers/subscriptions.php+++ b/bootstrap/helpers/subscriptions.php@@ -23,12 +23,21 @@ function getSubscriptionLink()}return $url;}-function getPaymentLink() {+function getPaymentLink()+{return auth()->user()->currentTeam()->subscription->lemon_update_payment_menthod_url;}-function getRenewDate() {+function getRenewDate()+{return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');}-function isSubscribed() {- return isCloud() && auth()->user()->currentTeam()->subscription?->lemon_status === 'active';-}\ No newline at end of file+function getEndDate()+{+ return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at)->format('Y-M-d H:i:s');+}+function isSubscribed()+{+ return+ auth()->user()?->currentTeam()?->subscription?->lemon_status === 'active' ||+ (auth()->user()?->currentTeam()?->subscription?->lemon_ends_at && Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at) > Carbon::now());+}diff --git a/config/app.php b/config/app.phpindex a3347a8cda..78df1ec8a5 100644--- a/config/app.php+++ b/config/app.php@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Facade;return [+ 'id' => env('APP_ID'),'port' => env('APP_PORT', 8000),/*|--------------------------------------------------------------------------diff --git a/config/coolify.php b/config/coolify.phpindex 715c3a3ea5..08634313df 100644--- a/config/coolify.php+++ b/config/coolify.php@@ -3,9 +3,8 @@return ['self_hosted' => env('SELF_HOSTED', true),'lemon_squeezy_webhook_secret' => env('LEMON_SQUEEZY_WEBHOOK_SECRET'),- 'lemon_squeezy_product_id' => env('LEMON_SQUEEZY_PRODUCT_ID'),'mux_enabled' => env('MUX_ENABLED', true),'dev_webhook' => env('SERVEO_URL'),'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'),'proxy_config_path' => env('BASE_CONFIG_PATH', '/data/coolify') . "/proxy",-];\ No newline at end of file+];diff --git a/database/migrations/2023_07_13_120721_add_license_to_instance_settings.php b/database/migrations/2023_07_13_120721_add_license_to_instance_settings.phpnew file mode 100644index 0000000000..69598ece15--- /dev/null+++ b/database/migrations/2023_07_13_120721_add_license_to_instance_settings.php@@ -0,0 +1,30 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('instance_settings', function (Blueprint $table) {+ $table->boolean('is_resale_license_active')->default(false);+ $table->string('resale_license')->nullable();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('instance_settings', function (Blueprint $table) {+ $table->dropColumn('is_resale_license_active');+ $table->dropColumn('resale_license');+ });+ }+};diff --git a/database/seeders/TeamSeeder.php b/database/seeders/TeamSeeder.phpindex d1b41a42ea..67c5ec4897 100644--- a/database/seeders/TeamSeeder.php+++ b/database/seeders/TeamSeeder.php@@ -16,7 +16,6 @@ class TeamSeeder extends Seeder$root_user_personal_team->save();$normal_user_in_root_team->teams()->attach($root_user_personal_team);-$normal_user_not_in_root_team = User::find(2);$normal_user_in_root_team_personal_team = Team::find(1);$normal_user_not_in_root_team->teams()->attach($normal_user_in_root_team_personal_team, ['role' => 'admin']);diff --git a/resources/views/components/layout-subscription.blade.php b/resources/views/components/layout-subscription.blade.phpnew file mode 100644index 0000000000..c87f0b104b--- /dev/null+++ b/resources/views/components/layout-subscription.blade.php@@ -0,0 +1,40 @@+<!DOCTYPE html>+<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">++<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <link rel="preconnect" href="https://api.fonts.coollabs.io" crossorigin>+ <link href="https://api.fonts.coollabs.io/css2?family=Inter&display=swap" rel="stylesheet">+ @env('local')+ <title>Coolify - localhost</title>+ @endenv+ @env('production')+ <title>{{ $title ?? 'Coolify' }}</title>+ @endenv+ <meta name="csrf-token" content="{{ csrf_token() }}">+ @vite(['resources/js/app.js', 'resources/css/app.css'])+ <style>+ [x-cloak] {+ display: none !important;+ }+ </style>+ @livewireStyles+</head>++<body>+ @livewireScripts+ <x-toaster-hub />+ <x-navbar-subscription />+ <main class="main">+ {{ $slot }}+ </main>+ <x-version class="fixed left-2 bottom-1" />+ <script>+ Livewire.on('reloadWindow', () => {+ window.location.reload();+ })+ </script>+</body>++</html>diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.phpindex efd60e5e98..5610dfff2b 100644--- a/resources/views/components/layout.blade.php+++ b/resources/views/components/layout.blade.php@@ -30,11 +30,9 @@@auth<x-toaster-hub /><x-navbar />- @if (isSubscribed())- <div class="fixed top-3 left-4" id="vue">- <magic-bar></magic-bar>- </div>- @endif+ <div class="fixed top-3 left-4" id="vue">+ <magic-bar></magic-bar>+ </div><main class="main">{{ $slot }}</main>diff --git a/resources/views/components/navbar-subscription.blade.php b/resources/views/components/navbar-subscription.blade.phpnew file mode 100644index 0000000000..de98e15206--- /dev/null+++ b/resources/views/components/navbar-subscription.blade.php@@ -0,0 +1,20 @@+@auth+ <nav class="fixed h-full overflow-hidden overflow-y-auto scrollbar">+ <ul class="flex flex-col h-full gap-4 menu flex-nowrap">+ <li class="pb-6" title="Logout">+ <form action="/logout" method="POST" class=" hover:bg-transparent">+ @csrf+ <button class="flex items-center gap-2 rounded-none hover:text-white hover:bg-transparent"> <svg+ xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M13 12v.01" />+ <path d="M3 21h18" />+ <path d="M5 21v-16a2 2 0 0 1 2 -2h7.5m2.5 10.5v7.5" />+ <path d="M14 7h7m-3 -3l3 3l-3 3" />+ </svg> Logout</button>+ </form>+ </li>+ </ul>+ </nav>+@endauthdiff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.phpindex 9ffa2658e3..bf0a2f3a2a 100644--- a/resources/views/components/navbar.blade.php+++ b/resources/views/components/navbar.blade.php@@ -1,5 +1,5 @@@auth- <nav class="fixed h-full overflow-hidden overflow-y-auto scrollbar" :class="{ isSubscribed() ? 'pt-14' : '' }">+ <nav class="fixed h-full overflow-hidden overflow-y-auto pt-14 scrollbar"><ul class="flex flex-col h-full gap-4 menu flex-nowrap"><li title="Dashboard"><a class="hover:bg-transparent" @if (!request()->is('/')) href="/" @endif>@@ -10,90 +10,88 @@</svg></a></li>- @if (isSubscribed())- <li title="Projects">- <a class="hover:bg-transparent" @if (!request()->is('projects')) href="/projects" @endif>+ <li title="Projects">+ <a class="hover:bg-transparent" @if (!request()->is('projects')) href="/projects" @endif>+ <svg xmlns="http://www.w3.org/2000/svg"+ class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning icon' : 'icon' }}"+ viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M12 4l-8 4l8 4l8 -4l-8 -4" />+ <path d="M4 12l8 4l8 -4" />+ <path d="M4 16l8 4l8 -4" />+ </svg>+ </a>+ </li>++ <li title="Servers">+ <a class="hover:bg-transparent" @if (!request()->is('servers')) href="/servers" @endif>+ <svg xmlns="http://www.w3.org/2000/svg"+ class="{{ request()->is('server/*') || request()->is('servers') ? 'text-warning icon' : 'icon' }}"+ viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M3 4m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v2a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z" />+ <path d="M15 20h-9a3 3 0 0 1 -3 -3v-2a3 3 0 0 1 3 -3h12" />+ <path d="M7 8v.01" />+ <path d="M7 16v.01" />+ <path d="M20 15l-2 3h3l-2 3" />+ </svg>+ </a>+ </li>+ @if (auth()->user()->isInstanceAdmin())+ <li title="Command Center">+ <a class="hover:bg-transparent" @if (!request()->is('command-center')) href="/command-center" @endif><svg xmlns="http://www.w3.org/2000/svg"- class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning icon' : 'icon' }}"- viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none"- stroke-linecap="round" stroke-linejoin="round">+ class="{{ request()->is('command-center') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M12 4l-8 4l8 4l8 -4l-8 -4" />- <path d="M4 12l8 4l8 -4" />- <path d="M4 16l8 4l8 -4" />+ <path d="M5 7l5 5l-5 5" />+ <path d="M12 19l7 0" /></svg></a></li>- <li title="Servers">- <a class="hover:bg-transparent" @if (!request()->is('servers')) href="/servers" @endif>+ <li title="Profile">+ <a class="hover:bg-transparent" @if (!request()->is('profile')) href="/profile" @endif>+ <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />+ <path d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" />+ <path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855" />+ </svg>+ </a>+ </li>+ <li title="Teams">+ <a class="hover:bg-transparent" href="{{ route('team.show') }}">+ <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"+ stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />+ <path d="M10 13a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />+ <path d="M8 21v-1a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v1" />+ <path d="M15 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />+ <path d="M17 10h2a2 2 0 0 1 2 2v1" />+ <path d="M5 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />+ <path d="M3 13v-1a2 2 0 0 1 2 -2h2" />+ </svg>+ </a>+ </li>+ <livewire:upgrade />+ <li title="Settings" class="mt-auto">+ <a class="hover:bg-transparent" @if (!request()->is('settings')) href="/settings" @endif><svg xmlns="http://www.w3.org/2000/svg"- class="{{ request()->is('server/*') || request()->is('servers') ? 'text-warning icon' : 'icon' }}"- viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none"- stroke-linecap="round" stroke-linejoin="round">+ class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"+ stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M3 4m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v2a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z" />- <path d="M15 20h-9a3 3 0 0 1 -3 -3v-2a3 3 0 0 1 3 -3h12" />- <path d="M7 8v.01" />- <path d="M7 16v.01" />- <path d="M20 15l-2 3h3l-2 3" />+ <path+ d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" />+ <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" /></svg></a></li>- @if (auth()->user()->isInstanceAdmin())- <li title="Command Center">- <a class="hover:bg-transparent" @if (!request()->is('command-center')) href="/command-center" @endif>- <svg xmlns="http://www.w3.org/2000/svg"- class="{{ request()->is('command-center') ? 'text-warning icon' : 'icon' }}"- viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none"- stroke-linecap="round" stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M5 7l5 5l-5 5" />- <path d="M12 19l7 0" />- </svg>- </a>- </li>-- <li title="Profile">- <a class="hover:bg-transparent" @if (!request()->is('profile')) href="/profile" @endif>- <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"- stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />- <path d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" />- <path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855" />- </svg>- </a>- </li>- <li title="Teams">- <a class="hover:bg-transparent" href="{{ route('team.show') }}">- <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"- stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path d="M10 13a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />- <path d="M8 21v-1a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v1" />- <path d="M15 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />- <path d="M17 10h2a2 2 0 0 1 2 2v1" />- <path d="M5 5a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />- <path d="M3 13v-1a2 2 0 0 1 2 -2h2" />- </svg>- </a>- </li>- <livewire:upgrade />- <li title="Settings" class="mt-auto">- <a class="hover:bg-transparent" @if (!request()->is('settings')) href="/settings" @endif>- <svg xmlns="http://www.w3.org/2000/svg"- class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}"- viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none"- stroke-linecap="round" stroke-linejoin="round">- <path stroke="none" d="M0 0h24v24H0z" fill="none" />- <path- d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z" />- <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />- </svg>- </a>- </li>- @endif@endif<li class="pb-6" title="Logout">diff --git a/resources/views/components/team/navbar.blade.php b/resources/views/components/team/navbar.blade.phpindex 4828581616..e1ca1a6901 100644--- a/resources/views/components/team/navbar.blade.php+++ b/resources/views/components/team/navbar.blade.php@@ -20,22 +20,20 @@@endif</ol></nav>- @if (isSubscribed())- <nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">- <a class="{{ request()->routeIs('team.show') ? 'text-white' : '' }}" href="{{ route('team.show') }}">- <button>General</button>- </a>- <a class="{{ request()->routeIs('team.members') ? 'text-white' : '' }}" href="{{ route('team.members') }}">- <button>Members</button>- </a>- <a class="{{ request()->routeIs('team.notifications') ? 'text-white' : '' }}"- href="{{ route('team.notifications') }}">- <button>Notifications</button>- </a>- <div class="flex-1"></div>+ <nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">+ <a class="{{ request()->routeIs('team.show') ? 'text-white' : '' }}" href="{{ route('team.show') }}">+ <button>General</button>+ </a>+ <a class="{{ request()->routeIs('team.members') ? 'text-white' : '' }}" href="{{ route('team.members') }}">+ <button>Members</button>+ </a>+ <a class="{{ request()->routeIs('team.notifications') ? 'text-white' : '' }}"+ href="{{ route('team.notifications') }}">+ <button>Notifications</button>+ </a>+ <div class="flex-1"></div>+ <div class="-mt-9"><livewire:switch-team />- @else- <livewire:switch-team />- @endif+ </div></nav></div>diff --git a/resources/views/livewire/check-license.blade.php b/resources/views/livewire/check-license.blade.phpnew file mode 100644index 0000000000..e0c5a8e500--- /dev/null+++ b/resources/views/livewire/check-license.blade.php@@ -0,0 +1,17 @@+<form wire:submit.prevent='submit' class="flex flex-col gap-2">+ <div class="w-32">+ <x-forms.checkbox id="settings.is_resale_license_active" label="Is license active?" disabled />+ </div>+ <div class="flex gap-2">+ <x-forms.input id="settings.resale_license" label="License" />+ <x-forms.input id="instance_id" label="Instance Id (do not change this)" disabled />+ </div>+ <x-forms.button type="submit">+ Check License+ </x-forms.button>+ @if (session()->has('error'))+ <div class="text-error">+ {{ session('error') }}+ </div>+ @endif+</form>diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.phpindex 2a52c11167..3e3df1a012 100644--- a/resources/views/livewire/settings/configuration.blade.php+++ b/resources/views/livewire/settings/configuration.blade.php@@ -10,6 +10,7 @@<div class="flex gap-2"><x-forms.input id="settings.fqdn" label="Coolify's Domain" /></div>+{{-- <div class="flex gap-2 "><x-forms.input type="number" id="settings.public_port_min" label="Public Port Min" /><x-forms.input type="number" id="settings.public_port_max" label="Public Port Max" />diff --git a/resources/views/livewire/switch-team.blade.php b/resources/views/livewire/switch-team.blade.phpindex 63c19b0ede..7c8d7b54a4 100644--- a/resources/views/livewire/switch-team.blade.php+++ b/resources/views/livewire/switch-team.blade.php@@ -1,4 +1,4 @@-<div class="w-64 -mt-9">+<div class="w-64"><x-forms.select wire:model="selectedTeamId"><option value="default" disabled selected>Switch team</option>@foreach (auth()->user()->teams as $team)diff --git a/resources/views/subscription.blade.php b/resources/views/subscription.blade.phpnew file mode 100644index 0000000000..e677d2739f--- /dev/null+++ b/resources/views/subscription.blade.php@@ -0,0 +1,41 @@+<x-layout-subscription>+ @if (auth()->user()->isInstanceAdmin())+ <div class="pb-10">+ <h3>Resale License</h3>+ <livewire:check-license />+ </div>+ @endif+ @if (!auth()->user()->isInstanceAdmin() && !$settings->is_resale_license_active)+ <div>Resale license is not active. Please contact your instance admin.</div>+ @endif+ @if ($settings->is_resale_license_active)+ <div class="flex gap-2">+ <h3>Subscription</h3>+ <livewire:switch-team />+ </div>+ <div class="flex items-center pb-8">+ <span>Currently active team: {{ session('currentTeam.name') }}</span>+ </div>+ @if (data_get(auth()->user()->currentTeam(),+ 'subscription'))+ <div>Status: {{ auth()->user()->currentTeam()->subscription->lemon_status }}</div>+ <div>Type: {{ auth()->user()->currentTeam()->subscription->lemon_variant_name }}</div>+ @if (auth()->user()->currentTeam()->subscription->lemon_status === 'cancelled')+ <div class="pb-4">Subscriptions ends at: {{ getEndDate() }}</div>+ <x-forms.button><a class="text-white" href="{{ getSubscriptionLink() }}">Subscribe+ Again</a>+ </x-forms.button>+ @else+ <div class="pb-4">Renews at: {{ getRenewDate() }}</div>+ @endif+ <x-forms.button><a class="text-white" href="{{ getPaymentLink() }}">Update Payment Details</a>+ </x-forms.button>+ @else+ <x-forms.button class="mt-4"><a class="text-white" href="{{ getSubscriptionLink() }}">Subscribe Now</a>+ </x-forms.button>+ @endif+ <x-forms.button><a class="text-white" href="https://app.lemonsqueezy.com/my-orders">Manage My+ Subscription</a>+ </x-forms.button>+ @endif+</x-layout-subscription>diff --git a/resources/views/team/show.blade.php b/resources/views/team/show.blade.phpindex 0c90a384df..001c680c7c 100644--- a/resources/views/team/show.blade.php+++ b/resources/views/team/show.blade.php@@ -1,8 +1,6 @@<x-layout><x-team.navbar :team="session('currentTeam')" />- @if (isSubscribed())- <livewire:team.form />- @endif+ <livewire:team.form />@if (isCloud())<div class="pb-8"><h3>Subscription</h3>@@ -29,7 +27,5 @@</x-forms.button></div>@endif- @if (isSubscribed())- <livewire:team.delete />- @endif+ <livewire:team.delete /></x-layout>diff --git a/routes/web.php b/routes/web.phpindex 0ab4d5c3f6..e1a0b16957 100644--- a/routes/web.php+++ b/routes/web.php@@ -84,7 +84,7 @@ Route::middleware(['auth'])->group(function () {Route::middleware(['auth'])->group(function () {Route::get('/', [Controller::class, 'dashboard'])->name('dashboard');- Route::get('/license', [Controller::class, 'license'])->name('license');+ Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription');Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');Route::get('/settings/emails', [Controller::class, 'emails'])->name('settings.emails');Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');diff --git a/routes/webhooks.php b/routes/webhooks.phpindex dd43009b4d..21a81d70ec 100644--- a/routes/webhooks.php+++ b/routes/webhooks.php@@ -176,8 +176,9 @@ Route::post('/source/github/events', function () {});if (isCloud()) {- Route::post('/subscriptions/events', function () {+ Route::post('/payments/events', function () {try {+$secret = config('coolify.lemon_squeezy_webhook_secret');$payload = request()->collect();$hash = hash_hmac('sha256', $payload, $secret);@@ -192,8 +193,12 @@ if (isCloud()) {'payload' => $payload]);$event = data_get($payload, 'meta.event_name');+ ray('Subscription event: ' . $event);$email = data_get($payload, 'data.attributes.user_email');$team_id = data_get($payload, 'meta.custom_data.team_id');+ if (is_null($team_id) || empty($team_id)) {+ throw new \Exception('No team_id found in webhook payload.');+ }$subscription_id = data_get($payload, 'data.id');$order_id = data_get($payload, 'data.attributes.order_id');$product_id = data_get($payload, 'data.attributes.product_id');@@ -218,7 +223,7 @@ if (isCloud()) {$subscription = Subscription::updateOrCreate(['team_id' => $team_id,], [- 'lemon_subscription_id'=> $subscription_id,+ 'lemon_subscription_id' => $subscription_id,'lemon_customer_id' => $customer_id,'lemon_order_id' => $order_id,'lemon_product_id' => $product_id,@@ -246,7 +251,6 @@ if (isCloud()) {}break;}- ray('Subscription event: ' . $event);$webhook->update(['status' => 'success',]);@@ -260,4 +264,4 @@ if (isCloud()) {return response('OK');}});-}\ No newline at end of file+}