From d8adea734f63af9b4441d8df6a87f064fb442c23 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 22 Jun 2023 14:48:47 +0200 Subject: [PATCH] basic license wip --- app/Http/Controllers/Controller.php | 4 +++ app/Http/Kernel.php | 1 + app/Http/Livewire/License.php | 26 ++++++++++++++++ app/Http/Middleware/LicenseValid.php | 30 +++++++++++++++++++ app/Providers/AppServiceProvider.php | 7 +---- .../views/components/layout-simple.blade.php | 2 ++ resources/views/license.blade.php | 4 +++ resources/views/livewire/license.blade.php | 6 ++++ routes/web.php | 1 + 9 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 app/Http/Livewire/License.php create mode 100644 app/Http/Middleware/LicenseValid.php create mode 100644 resources/views/license.blade.php create mode 100644 resources/views/livewire/license.blade.php diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index e7a7e0b5d..673409ba6 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -17,6 +17,10 @@ class Controller extends BaseController { use AuthorizesRequests, ValidatesRequests; + public function license() + { + return view('license'); + } public function dashboard() { $projects = Project::ownedByCurrentTeam()->get(); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index f25f52c39..7beaad19e 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -21,6 +21,7 @@ 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/License.php b/app/Http/Livewire/License.php new file mode 100644 index 000000000..14c147a87 --- /dev/null +++ b/app/Http/Livewire/License.php @@ -0,0 +1,26 @@ +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'); + // } + } +} diff --git a/app/Http/Middleware/LicenseValid.php b/app/Http/Middleware/LicenseValid.php new file mode 100644 index 000000000..099092ff9 --- /dev/null +++ b/app/Http/Middleware/LicenseValid.php @@ -0,0 +1,30 @@ +path()); + if ($request->path() !== 'license' && $request->path() !== 'livewire/message/license') { + return redirect('license'); + } + } + } + return $next($request); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 9fa586116..b8c70b770 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,21 +2,16 @@ namespace App\Providers; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { - /** - * Register any application services. - */ public function register(): void { } - /** - * Bootstrap any application services. - */ public function boot(): void { Http::macro('github', function (string $api_url, string|null $github_access_token = null) { diff --git a/resources/views/components/layout-simple.blade.php b/resources/views/components/layout-simple.blade.php index 6fe145a74..604768ccd 100644 --- a/resources/views/components/layout-simple.blade.php +++ b/resources/views/components/layout-simple.blade.php @@ -19,9 +19,11 @@ display: none !important; } + @livewireStyles + @livewireScripts
{{ $slot }}
diff --git a/resources/views/license.blade.php b/resources/views/license.blade.php new file mode 100644 index 000000000..4db900f17 --- /dev/null +++ b/resources/views/license.blade.php @@ -0,0 +1,4 @@ + +

Lincese Key

+ +
diff --git a/resources/views/livewire/license.blade.php b/resources/views/livewire/license.blade.php new file mode 100644 index 000000000..a367c124e --- /dev/null +++ b/resources/views/livewire/license.blade.php @@ -0,0 +1,6 @@ +
+
+ + Check + +
diff --git a/routes/web.php b/routes/web.php index 73e858d64..49d82dc77 100644 --- a/routes/web.php +++ b/routes/web.php @@ -86,6 +86,7 @@ Route::middleware(['auth'])->group(function () { 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/emails', [Controller::class, 'emails'])->name('settings.emails'); Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');