basic license wip
This commit is contained in:
parent
fa2f34ba3c
commit
d8adea734f
@ -17,6 +17,10 @@ class Controller extends BaseController
|
|||||||
{
|
{
|
||||||
use AuthorizesRequests, ValidatesRequests;
|
use AuthorizesRequests, ValidatesRequests;
|
||||||
|
|
||||||
|
public function license()
|
||||||
|
{
|
||||||
|
return view('license');
|
||||||
|
}
|
||||||
public function dashboard()
|
public function dashboard()
|
||||||
{
|
{
|
||||||
$projects = Project::ownedByCurrentTeam()->get();
|
$projects = Project::ownedByCurrentTeam()->get();
|
||||||
|
@ -21,6 +21,7 @@ class Kernel extends HttpKernel
|
|||||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
\App\Http\Middleware\TrimStrings::class,
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
// \App\Http\Middleware\LicenseValid::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
26
app/Http/Livewire/License.php
Normal file
26
app/Http/Livewire/License.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class License extends Component
|
||||||
|
{
|
||||||
|
public string $license;
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
ray('checking license');
|
||||||
|
$this->validate([
|
||||||
|
'license' => 'required'
|
||||||
|
]);
|
||||||
|
// Pretend we're checking the license
|
||||||
|
// if ($this->license === '123') {
|
||||||
|
// ray('license is valid');
|
||||||
|
// Cache::put('license_key', '123');
|
||||||
|
// return redirect()->to('/');
|
||||||
|
// } else {
|
||||||
|
// ray('license is invalid');
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
30
app/Http/Middleware/LicenseValid.php
Normal file
30
app/Http/Middleware/LicenseValid.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class LicenseValid
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (!config('coolify.self_hosted')) {
|
||||||
|
$value = Cache::get('license_key');
|
||||||
|
if (!$value) {
|
||||||
|
ray($request->path());
|
||||||
|
if ($request->path() !== 'license' && $request->path() !== 'livewire/message/license') {
|
||||||
|
return redirect('license');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@ -2,21 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Register any application services.
|
|
||||||
*/
|
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap any application services.
|
|
||||||
*/
|
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Http::macro('github', function (string $api_url, string|null $github_access_token = null) {
|
Http::macro('github', function (string $api_url, string|null $github_access_token = null) {
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@livewireStyles
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@livewireScripts
|
||||||
<main>
|
<main>
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</main>
|
</main>
|
||||||
|
4
resources/views/license.blade.php
Normal file
4
resources/views/license.blade.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<x-layout-simple>
|
||||||
|
<h1>Lincese Key</h1>
|
||||||
|
<livewire:license />
|
||||||
|
</x-layout-simple>
|
6
resources/views/livewire/license.blade.php
Normal file
6
resources/views/livewire/license.blade.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div>
|
||||||
|
<form wire:submit.prevent='submit'>
|
||||||
|
<x-forms.input id="license" label="License Key" />
|
||||||
|
<x-forms.button type='submit'>Check</x-forms.button>
|
||||||
|
</form>
|
||||||
|
</div>
|
@ -86,6 +86,7 @@
|
|||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/', [Controller::class, 'dashboard'])->name('dashboard');
|
Route::get('/', [Controller::class, 'dashboard'])->name('dashboard');
|
||||||
|
Route::get('/license', [Controller::class, 'license'])->name('license');
|
||||||
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('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
||||||
|
Loading…
Reference in New Issue
Block a user