move settings to new page
This commit is contained in:
parent
f27b8a00f1
commit
6ea60fcbb5
@ -63,3 +63,5 @@ AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
SETTINGS_PASSWORD=admin
|
||||
|
||||
38
app/Http/Controllers/SettingsController.php
Normal file
38
app/Http/Controllers/SettingsController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
public function login(): View
|
||||
{
|
||||
return view('settings-login');
|
||||
}
|
||||
|
||||
public function authenticate(Request $request): RedirectResponse
|
||||
{
|
||||
$password = env('SETTINGS_PASSWORD', 'admin');
|
||||
|
||||
if ($request->input('password') === $password) {
|
||||
session(['settings_authenticated' => true]);
|
||||
return redirect()->route('settings');
|
||||
}
|
||||
|
||||
return back()->withErrors(['password' => 'Falsches Passwort.']);
|
||||
}
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
return view('settings');
|
||||
}
|
||||
|
||||
public function logout(): RedirectResponse
|
||||
{
|
||||
session()->forget('settings_authenticated');
|
||||
return redirect()->route('settings.login');
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/SettingsPassword.php
Normal file
19
app/Http/Middleware/SettingsPassword.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SettingsPassword
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (!session('settings_authenticated')) {
|
||||
return redirect()->route('settings.login');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@ -15,8 +15,6 @@
|
||||
|
||||
@livewire('camera-capture')
|
||||
|
||||
@livewire('photo-settings')
|
||||
|
||||
@livewireScripts
|
||||
</body>
|
||||
</html>
|
||||
|
||||
46
resources/views/settings-login.blade.php
Normal file
46
resources/views/settings-login.blade.php
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Einstellungen – Fotobox</title>
|
||||
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
@endif
|
||||
</head>
|
||||
<body class="bg-gray-950 text-white min-h-screen flex items-center justify-center p-6">
|
||||
|
||||
<div class="w-full max-w-sm">
|
||||
<h1 class="text-2xl font-bold text-center mb-8 tracking-wide">Einstellungen</h1>
|
||||
|
||||
<form method="POST" action="{{ route('settings.authenticate') }}" class="space-y-4">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Passwort"
|
||||
autofocus
|
||||
class="w-full px-4 py-3 rounded-xl bg-gray-900 border {{ $errors->has('password') ? 'border-red-500' : 'border-gray-700' }} text-white placeholder-gray-500 focus:outline-none focus:border-gray-500 text-sm">
|
||||
|
||||
@error('password')
|
||||
<p class="mt-2 text-sm text-red-400">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="w-full py-3 bg-white text-gray-950 font-semibold rounded-xl hover:bg-gray-200 active:scale-95 transition-all duration-150 text-sm">
|
||||
Anmelden
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<a href="{{ route('camera') }}" class="text-sm text-gray-600 hover:text-gray-400 transition-colors">
|
||||
← Zurück zur Fotobox
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
35
resources/views/settings.blade.php
Normal file
35
resources/views/settings.blade.php
Normal file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Einstellungen – Fotobox</title>
|
||||
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
@endif
|
||||
@livewireStyles
|
||||
</head>
|
||||
<body class="bg-gray-950 text-white min-h-screen flex flex-col items-center p-6">
|
||||
|
||||
<div class="w-full max-w-2xl">
|
||||
<div class="flex items-center justify-between mb-10">
|
||||
<h1 class="text-2xl font-bold tracking-wide">Einstellungen</h1>
|
||||
<div class="flex items-center gap-4">
|
||||
<a href="{{ route('camera') }}" class="text-sm text-gray-500 hover:text-gray-300 transition-colors">
|
||||
← Fotobox
|
||||
</a>
|
||||
<form method="POST" action="{{ route('settings.logout') }}">
|
||||
@csrf
|
||||
<button type="submit" class="text-sm text-gray-600 hover:text-red-400 transition-colors">
|
||||
Abmelden
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@livewire('photo-settings')
|
||||
</div>
|
||||
|
||||
@livewireScripts
|
||||
</body>
|
||||
</html>
|
||||
@ -1,8 +1,18 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\PhotoController;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use App\Http\Middleware\SettingsPassword;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', [PhotoController::class, 'index'])
|
||||
->middleware(\App\Http\Middleware\RestrictToSubnet::class)
|
||||
->name('camera');
|
||||
|
||||
Route::get('/settings/login', [SettingsController::class, 'login'])->name('settings.login');
|
||||
Route::post('/settings/login', [SettingsController::class, 'authenticate'])->name('settings.authenticate');
|
||||
Route::post('/settings/logout', [SettingsController::class, 'logout'])->name('settings.logout');
|
||||
|
||||
Route::get('/settings', [SettingsController::class, 'index'])
|
||||
->middleware(SettingsPassword::class)
|
||||
->name('settings');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user