wip
This commit is contained in:
parent
a96fb46296
commit
9f4342bd19
@ -19,10 +19,22 @@ class Controller extends BaseController
|
|||||||
|
|
||||||
public function subscription()
|
public function subscription()
|
||||||
{
|
{
|
||||||
|
if (!isCloud()) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
return view('subscription', [
|
return view('subscription', [
|
||||||
'settings' => InstanceSettings::get()
|
'settings' => InstanceSettings::get()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
public function license()
|
||||||
|
{
|
||||||
|
if (!isCloud()) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
return view('settings.license', [
|
||||||
|
'settings' => InstanceSettings::get()
|
||||||
|
]);
|
||||||
|
}
|
||||||
public function dashboard()
|
public function dashboard()
|
||||||
{
|
{
|
||||||
$projects = Project::ownedByCurrentTeam()->get();
|
$projects = Project::ownedByCurrentTeam()->get();
|
||||||
|
@ -35,7 +35,7 @@ public function submit()
|
|||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
session()->flash('error', 'License is not valid. Please contact support.');
|
session()->flash('error', 'License is not valid. Please contact support.');
|
||||||
ray($th->getMessage());
|
ray($th->getMessage());
|
||||||
return redirect()->to('/subscription');
|
return redirect()->to('/settings/license');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,10 @@ class SubscriptionValid
|
|||||||
|
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
|
if (auth()->user()) {
|
||||||
|
if (isCloud() && !isSubscribed()) {
|
||||||
|
ray('SubscriptionValid Middleware');
|
||||||
|
|
||||||
$allowed_paths = [
|
$allowed_paths = [
|
||||||
'subscription',
|
'subscription',
|
||||||
'login',
|
'login',
|
||||||
@ -19,19 +23,19 @@ public function handle(Request $request, Closure $next): Response
|
|||||||
'livewire/message/check-license',
|
'livewire/message/check-license',
|
||||||
'livewire/message/switch-team',
|
'livewire/message/switch-team',
|
||||||
];
|
];
|
||||||
if (isCloud() && !isSubscribed()) {
|
|
||||||
ray('SubscriptionValid Middleware');
|
|
||||||
if (!in_array($request->path(), $allowed_paths)) {
|
if (!in_array($request->path(), $allowed_paths)) {
|
||||||
return redirect('subscription');
|
return redirect('subscription');
|
||||||
} else {
|
} else {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($request->path() === 'subscription') {
|
if ($request->path() === 'subscription' && !auth()->user()->isInstanceAdmin()) {
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
} else {
|
} else {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ class InstanceSettings extends Model implements SendsEmail
|
|||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'smtp' => SchemalessAttributes::class,
|
'smtp' => SchemalessAttributes::class,
|
||||||
|
'resale_license' => 'encrypted',
|
||||||
];
|
];
|
||||||
public function scopeWithSmtp(): Builder
|
public function scopeWithSmtp(): Builder
|
||||||
{
|
{
|
||||||
|
@ -16,13 +16,12 @@ public function __construct(
|
|||||||
public string|null $type = 'text',
|
public string|null $type = 'text',
|
||||||
public string|null $value = null,
|
public string|null $value = null,
|
||||||
public string|null $label = null,
|
public string|null $label = null,
|
||||||
public string|null $placeholder = null,
|
|
||||||
public bool $required = false,
|
public bool $required = false,
|
||||||
public bool $disabled = false,
|
public bool $disabled = false,
|
||||||
public bool $readonly = false,
|
public bool $readonly = false,
|
||||||
public string|null $helper = null,
|
public string|null $helper = null,
|
||||||
public bool $allowToPeak = true,
|
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"
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,5 +130,5 @@ function isDev()
|
|||||||
}
|
}
|
||||||
function isCloud()
|
function isCloud()
|
||||||
{
|
{
|
||||||
return (bool)config('coolify.self_hosted') === false;
|
return !config('coolify.self_hosted');
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,13 @@ function getRenewDate()
|
|||||||
}
|
}
|
||||||
function getEndDate()
|
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()
|
function isSubscribed()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
auth()->user()?->currentTeam()?->subscription?->lemon_status === 'active' ||
|
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();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public function up(): void
|
|||||||
{
|
{
|
||||||
Schema::table('instance_settings', function (Blueprint $table) {
|
Schema::table('instance_settings', function (Blueprint $table) {
|
||||||
$table->boolean('is_resale_license_active')->default(false);
|
$table->boolean('is_resale_license_active')->default(false);
|
||||||
$table->string('resale_license')->nullable();
|
$table->longText('resale_license')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,37 @@
|
|||||||
<body>
|
<body>
|
||||||
@livewireScripts
|
@livewireScripts
|
||||||
<x-toaster-hub />
|
<x-toaster-hub />
|
||||||
|
@if (auth()->user()->isInstanceAdmin())
|
||||||
|
<div class="fixed top-3 left-4" id="vue">
|
||||||
|
<magic-bar></magic-bar>
|
||||||
|
</div>
|
||||||
|
<x-navbar />
|
||||||
|
@else
|
||||||
<x-navbar-subscription />
|
<x-navbar-subscription />
|
||||||
|
@endif
|
||||||
|
|
||||||
<main class="main">
|
<main class="main">
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</main>
|
</main>
|
||||||
<x-version class="fixed left-2 bottom-1" />
|
<x-version class="fixed left-2 bottom-1" />
|
||||||
<script>
|
<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', () => {
|
Livewire.on('reloadWindow', () => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
|
@ -93,11 +93,11 @@ class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox=
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
<div class="flex-1"></div>
|
||||||
<li class="pb-6" title="Logout">
|
<li class="pb-6" title="Logout">
|
||||||
<form action="/logout" method="POST" class=" hover:bg-transparent">
|
<form action="/logout" method="POST" class=" hover:bg-transparent">
|
||||||
@csrf
|
@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"
|
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">
|
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
@ -9,6 +9,12 @@
|
|||||||
<a class="{{ request()->routeIs('settings.emails') ? 'text-white' : '' }}" href="{{ route('settings.emails') }}">
|
<a class="{{ request()->routeIs('settings.emails') ? 'text-white' : '' }}" href="{{ route('settings.emails') }}">
|
||||||
<button>SMTP</button>
|
<button>SMTP</button>
|
||||||
</a>
|
</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>
|
<div class="flex-1"></div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<x-layout-simple>
|
|
||||||
<h1>Lincese Key</h1>
|
|
||||||
<livewire:license />
|
|
||||||
</x-layout-simple>
|
|
@ -1,14 +1,21 @@
|
|||||||
<form wire:submit.prevent='submit' class="flex flex-col gap-2">
|
<form wire:submit.prevent='submit' class="flex flex-col gap-2">
|
||||||
<div class="w-32">
|
<div>
|
||||||
<x-forms.checkbox id="settings.is_resale_license_active" label="Is license active?" disabled />
|
@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>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<x-forms.input id="settings.resale_license" label="License" />
|
<x-forms.input type="password" id="settings.resale_license" placeholder="eg: BE558E91-0CC5-4AA2-B1C0-B6403C2988DD"
|
||||||
<x-forms.input id="instance_id" label="Instance Id (do not change this)" disabled />
|
label="License Key" />
|
||||||
|
<x-forms.input type="password" id="instance_id" label="Instance Id (do not change this)" disabled />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex gap-2">
|
||||||
<x-forms.button type="submit">
|
<x-forms.button type="submit">
|
||||||
Check License
|
Check License
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
</div>
|
||||||
@if (session()->has('error'))
|
@if (session()->has('error'))
|
||||||
<div class="text-error">
|
<div class="text-error">
|
||||||
{{ session('error') }}
|
{{ session('error') }}
|
||||||
|
5
resources/views/settings/license.blade.php
Normal file
5
resources/views/settings/license.blade.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<x-layout-subscription>
|
||||||
|
<x-settings.navbar />
|
||||||
|
<h3>Resale License</h3>
|
||||||
|
<livewire:check-license />
|
||||||
|
</x-layout-subscription>
|
@ -1,13 +1,4 @@
|
|||||||
<x-layout-subscription>
|
<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)
|
@if ($settings->is_resale_license_active)
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<h3>Subscription</h3>
|
<h3>Subscription</h3>
|
||||||
@ -37,5 +28,7 @@
|
|||||||
<x-forms.button><a class="text-white" href="https://app.lemonsqueezy.com/my-orders">Manage My
|
<x-forms.button><a class="text-white" href="https://app.lemonsqueezy.com/my-orders">Manage My
|
||||||
Subscription</a>
|
Subscription</a>
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
@else
|
||||||
|
<div>Resale license is not active. Please contact your instance admin.</div>
|
||||||
@endif
|
@endif
|
||||||
</x-layout-subscription>
|
</x-layout-subscription>
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription');
|
Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription');
|
||||||
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
||||||
Route::get('/settings/emails', [Controller::class, 'emails'])->name('settings.emails');
|
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('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
||||||
Route::get('/team', [Controller::class, 'team'])->name('team.show');
|
Route::get('/team', [Controller::class, 'team'])->name('team.show');
|
||||||
Route::get('/team/new', fn () => view('team.create'))->name('team.create');
|
Route::get('/team/new', fn () => view('team.create'))->name('team.create');
|
||||||
|
Loading…
Reference in New Issue
Block a user