Skip to content

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.

wip

Andras Bacsai9f4342bd1944
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 98faaad2eb..c9620f4bd1 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -19,10 +19,22 @@ class Controller extends BaseController
public function subscription()
{
+ if (!isCloud()) {
+ abort(404);
+ }
return view('subscription', [
'settings' => InstanceSettings::get()
]);
}
+ public function license()
+ {
+ if (!isCloud()) {
+ abort(404);
+ }
+ return view('settings.license', [
+ 'settings' => InstanceSettings::get()
+ ]);
+ }
public function dashboard()
{
$projects = Project::ownedByCurrentTeam()->get();
diff --git a/app/Http/Livewire/CheckLicense.php b/app/Http/Livewire/CheckLicense.php
index 59942c6a63..38ee0e6360 100644
--- a/app/Http/Livewire/CheckLicense.php
+++ b/app/Http/Livewire/CheckLicense.php
@@ -35,7 +35,7 @@ class CheckLicense extends Component
} catch (\Throwable $th) {
session()->flash('error', 'License is not valid. Please contact support.');
ray($th->getMessage());
- return redirect()->to('/subscription');
+ return redirect()->to('/settings/license');
}
}
}
diff --git a/app/Http/Middleware/SubscriptionValid.php b/app/Http/Middleware/SubscriptionValid.php
index ab2d9eb1f3..e7fcdff3cb 100644
--- a/app/Http/Middleware/SubscriptionValid.php
+++ b/app/Http/Middleware/SubscriptionValid.php
@@ -11,27 +11,31 @@ class SubscriptionValid
public function handle(Request $request, Closure $next): Response
{
- $allowed_paths = [
- 'subscription',
- 'login',
- 'register',
- 'logout',
- 'livewire/message/check-license',
- 'livewire/message/switch-team',
- ];
- if (isCloud() && !isSubscribed()) {
- ray('SubscriptionValid Middleware');
- if (!in_array($request->path(), $allowed_paths)) {
- return redirect('subscription');
- } else {
- return $next($request);
- }
- } else {
- if ($request->path() === 'subscription') {
- return redirect('/');
+ if (auth()->user()) {
+ if (isCloud() && !isSubscribed()) {
+ ray('SubscriptionValid Middleware');
+
+ $allowed_paths = [
+ 'subscription',
+ 'login',
+ 'register',
+ 'logout',
+ 'livewire/message/check-license',
+ 'livewire/message/switch-team',
+ ];
+ if (!in_array($request->path(), $allowed_paths)) {
+ return redirect('subscription');
+ } else {
+ return $next($request);
+ }
} else {
- return $next($request);
+ if ($request->path() === 'subscription' && !auth()->user()->isInstanceAdmin()) {
+ return redirect('/');
+ } else {
+ return $next($request);
+ }
}
}
+ return $next($request);
}
}
diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php
index 5f0cc8c004..b5c01f1fb2 100644
--- a/app/Models/InstanceSettings.php
+++ b/app/Models/InstanceSettings.php
@@ -18,6 +18,7 @@ class InstanceSettings extends Model implements SendsEmail
];
protected $casts = [
'smtp' => SchemalessAttributes::class,
+ 'resale_license' => 'encrypted',
];
public function scopeWithSmtp(): Builder
{
diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.php
index c1dc45819b..b22bc11dc6 100644
--- a/app/View/Components/Forms/Input.php
+++ b/app/View/Components/Forms/Input.php
@@ -16,13 +16,12 @@ class Input extends Component
public string|null $type = 'text',
public string|null $value = null,
public string|null $label = null,
- public string|null $placeholder = null,
public bool $required = false,
public bool $disabled = false,
public bool $readonly = false,
public string|null $helper = null,
public bool $allowToPeak = true,
- public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none"
+ public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none placeholder:text-coolgray-500"
) {
}
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index f458256862..71a2f35605 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -130,5 +130,5 @@ function isDev()
}
function isCloud()
{
- return (bool)config('coolify.self_hosted') === false;
+ return !config('coolify.self_hosted');
}
diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php
index 319212fd4a..7e291fabc0 100644
--- a/bootstrap/helpers/subscriptions.php
+++ b/bootstrap/helpers/subscriptions.php
@@ -33,11 +33,13 @@ function getRenewDate()
}
function getEndDate()
{
- return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at)->format('Y-M-d H:i:s');
+ return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_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());
+ (auth()->user()?->currentTeam()?->subscription?->lemon_ends_at &&
+ Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at) > Carbon::now()
+ ) || auth()->user()->isInstanceAdmin();
}
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.php
index 69598ece15..c32cd0f9a5 100644
--- 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.php
@@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::table('instance_settings', function (Blueprint $table) {
$table->boolean('is_resale_license_active')->default(false);
- $table->string('resale_license')->nullable();
+ $table->longText('resale_license')->nullable();
});
}
diff --git a/resources/views/components/layout-subscription.blade.php b/resources/views/components/layout-subscription.blade.php
index c87f0b104b..3feb216288 100644
--- a/resources/views/components/layout-subscription.blade.php
+++ b/resources/views/components/layout-subscription.blade.php
@@ -25,12 +25,37 @@
<body>
@livewireScripts
<x-toaster-hub />
- <x-navbar-subscription />
+ @if (auth()->user()->isInstanceAdmin())
+ <div class="fixed top-3 left-4" id="vue">
+ <magic-bar></magic-bar>
+ </div>
+ <x-navbar />
+ @else
+ <x-navbar-subscription />
+ @endif
+
<main class="main">
{{ $slot }}
</main>
<x-version class="fixed left-2 bottom-1" />
<script>
+ function changePasswordFieldType(event) {
+ let element = event.target
+ for (let i = 0; i < 10; i++) {
+ if (element.className === "relative") {
+ break;
+ }
+ element = element.parentElement;
+ }
+ element = element.children[1];
+ if (element.nodeName === 'INPUT') {
+ if (element.type === 'password') {
+ element.type = 'text';
+ } else {
+ element.type = 'password';
+ }
+ }
+ }
Livewire.on('reloadWindow', () => {
window.location.reload();
})
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php
index bf0a2f3a2a..e276250032 100644
--- a/resources/views/components/navbar.blade.php
+++ b/resources/views/components/navbar.blade.php
@@ -93,11 +93,11 @@
</a>
</li>
@endif
-
+ <div class="flex-1"></div>
<li class="pb-6" title="Logout">
<form action="/logout" method="POST" class=" hover:bg-transparent">
@csrf
- <button class="rounded-none hover:text-white hover:bg-transparent"> <svg
+ <button type="submit" class="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" />
diff --git a/resources/views/components/settings/navbar.blade.php b/resources/views/components/settings/navbar.blade.php
index 797bb77561..3f671a3d97 100644
--- a/resources/views/components/settings/navbar.blade.php
+++ b/resources/views/components/settings/navbar.blade.php
@@ -9,6 +9,12 @@
<a class="{{ request()->routeIs('settings.emails') ? 'text-white' : '' }}" href="{{ route('settings.emails') }}">
<button>SMTP</button>
</a>
+ @if (isCloud())
+ <a class="{{ request()->routeIs('settings.license') ? 'text-white' : '' }}"
+ href="{{ route('settings.license') }}">
+ <button>Resale License</button>
+ </a>
+ @endif
<div class="flex-1"></div>
</nav>
</div>
diff --git a/resources/views/license.blade.php b/resources/views/license.blade.php
deleted file mode 100644
index 4db900f17f..0000000000
--- a/resources/views/license.blade.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<x-layout-simple>
- <h1>Lincese Key</h1>
- <livewire:license />
-</x-layout-simple>
diff --git a/resources/views/livewire/check-license.blade.php b/resources/views/livewire/check-license.blade.php
index e0c5a8e500..8f055da817 100644
--- a/resources/views/livewire/check-license.blade.php
+++ b/resources/views/livewire/check-license.blade.php
@@ -1,14 +1,21 @@
<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>
+ @if ($settings->is_resale_license_active)
+ <div class="text-success">License is active</div>
+ @else
+ <div class="text-error">License is not active</div>
+ @endif
</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 />
+ <x-forms.input type="password" id="settings.resale_license" placeholder="eg: BE558E91-0CC5-4AA2-B1C0-B6403C2988DD"
+ label="License Key" />
+ <x-forms.input type="password" id="instance_id" label="Instance Id (do not change this)" disabled />
+ </div>
+ <div class="flex gap-2">
+ <x-forms.button type="submit">
+ Check License
+ </x-forms.button>
</div>
- <x-forms.button type="submit">
- Check License
- </x-forms.button>
@if (session()->has('error'))
<div class="text-error">
{{ session('error') }}
diff --git a/resources/views/settings/license.blade.php b/resources/views/settings/license.blade.php
new file mode 100644
index 0000000000..6450d39710
--- /dev/null
+++ b/resources/views/settings/license.blade.php
@@ -0,0 +1,5 @@
+<x-layout-subscription>
+ <x-settings.navbar />
+ <h3>Resale License</h3>
+ <livewire:check-license />
+</x-layout-subscription>
diff --git a/resources/views/subscription.blade.php b/resources/views/subscription.blade.php
index e677d2739f..d70c8e4957 100644
--- a/resources/views/subscription.blade.php
+++ b/resources/views/subscription.blade.php
@@ -1,13 +1,4 @@
<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>
@@ -37,5 +28,7 @@
<x-forms.button><a class="text-white" href="https://app.lemonsqueezy.com/my-orders">Manage My
Subscription</a>
</x-forms.button>
+ @else
+ <div>Resale license is not active. Please contact your instance admin.</div>
@endif
</x-layout-subscription>
diff --git a/routes/web.php b/routes/web.php
index e1a0b16957..b72fc889d5 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -87,6 +87,7 @@ Route::middleware(['auth'])->group(function () {
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('/settings/license', [Controller::class, 'license'])->name('settings.license');
Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
Route::get('/team', [Controller::class, 'team'])->name('team.show');
Route::get('/team/new', fn () => view('team.create'))->name('team.create');