Fix auth form errors and redirects: Add React keys/useEffects for error rendering and scroll, Inertia::location in controllers for SPA navigation, extend RegistrationTest and add E2E. Update docs (changes/2025-10-02-registration-fixes.md, prp/13-backend-authentication.md). Add new UI components (accordion, carousel, progress, table, tabs), marketing/legal pages (Blog, Kontakt, Datenschutz, etc.), fonts, user migration (remove_name), views/css/package updates, seeders/factories.
This commit is contained in:
@@ -19,6 +19,10 @@ class AddDummyTenantUser extends Command
|
||||
{--password=secret123!}
|
||||
{--tenant="Demo Tenant"}
|
||||
{--name="Demo Admin"}
|
||||
{--first_name="Demo"}
|
||||
{--last_name="Admin"}
|
||||
{--address="Demo Str. 1, 12345 Demo City"}
|
||||
{--phone="+49 123 4567890"}
|
||||
{--update-password : Overwrite password if user already exists}
|
||||
';
|
||||
protected $description = 'Create a demo tenant and a tenant user with given credentials.';
|
||||
@@ -29,6 +33,12 @@ class AddDummyTenantUser extends Command
|
||||
$password = (string) $this->option('password');
|
||||
$tenantName = (string) $this->option('tenant');
|
||||
$userName = (string) $this->option('name');
|
||||
$firstName = (string) $this->option('first_name');
|
||||
$lastName = (string) $this->option('last_name');
|
||||
$address = (string) $this->option('address');
|
||||
$phone = (string) $this->option('phone');
|
||||
|
||||
$this->info('Starting dummy tenant creation with email: ' . $email);
|
||||
|
||||
// Pre-flight checks for common failures
|
||||
if (! Schema::hasTable('users')) {
|
||||
@@ -53,12 +63,17 @@ class AddDummyTenantUser extends Command
|
||||
$tenant->domain = null;
|
||||
$tenant->contact_name = $userName;
|
||||
$tenant->contact_email = $email;
|
||||
$tenant->contact_phone = null;
|
||||
$tenant->contact_phone = $phone ?: null;
|
||||
$tenant->event_credits_balance = 1;
|
||||
$tenant->max_photos_per_event = 500;
|
||||
$tenant->max_storage_mb = 1024;
|
||||
$tenant->features = ['custom_branding' => false];
|
||||
$tenant->is_active = true;
|
||||
$tenant->is_suspended = false;
|
||||
$tenant->save();
|
||||
$this->info('Created new tenant: ' . $tenant->name);
|
||||
} else {
|
||||
$this->info('Using existing tenant: ' . $tenant->name);
|
||||
}
|
||||
|
||||
// Create or fetch user
|
||||
@@ -70,9 +85,15 @@ class AddDummyTenantUser extends Command
|
||||
if (Schema::hasColumn($user->getTable(), 'name')) $user->name = $userName;
|
||||
$user->email = $email;
|
||||
$user->password = Hash::make($password);
|
||||
$this->info('Creating new user: ' . $email);
|
||||
} else if ($updatePassword) {
|
||||
$user->password = Hash::make($password);
|
||||
$this->info('Updating password for existing user: ' . $email);
|
||||
}
|
||||
if (Schema::hasColumn($user->getTable(), 'first_name')) $user->first_name = $firstName;
|
||||
if (Schema::hasColumn($user->getTable(), 'last_name')) $user->last_name = $lastName;
|
||||
if (Schema::hasColumn($user->getTable(), 'address')) $user->address = $address;
|
||||
if (Schema::hasColumn($user->getTable(), 'phone')) $user->phone = $phone;
|
||||
if (Schema::hasColumn($user->getTable(), 'tenant_id')) {
|
||||
$user->tenant_id = $tenant->id;
|
||||
}
|
||||
@@ -80,11 +101,13 @@ class AddDummyTenantUser extends Command
|
||||
$user->role = 'tenant_admin';
|
||||
}
|
||||
$user->save();
|
||||
$this->info('User saved successfully.');
|
||||
|
||||
DB::commit();
|
||||
} catch (\Throwable $e) {
|
||||
DB::rollBack();
|
||||
$this->error('Failed: '.$e->getMessage());
|
||||
$this->error('Stack trace: ' . $e->getTraceAsString());
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
56
app/Exceptions/Handler.php
Normal file
56
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
public function render($request, Throwable $e)
|
||||
{
|
||||
\Illuminate\Support\Facades\Log::info('Handler render called', ['inertia' => $request->inertia(), 'exception' => get_class($e)]);
|
||||
if ($request->inertia()) {
|
||||
if ($e instanceof ValidationException) {
|
||||
\Illuminate\Support\Facades\Log::info('ValidationException in Inertia', ['errors' => $e->errors()]);
|
||||
return response()->json([
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => $e->errors(),
|
||||
], 422)->header('X-Inertia-Error', 'true');
|
||||
}
|
||||
|
||||
if ($e instanceof \Exception) {
|
||||
\Illuminate\Support\Facades\Log::info('Exception in Inertia', ['message' => $e->getMessage()]);
|
||||
return response()->json([
|
||||
'message' => 'Registrierung fehlgeschlagen.',
|
||||
'errors' => ['general' => $e->getMessage()],
|
||||
], 500)->header('X-Inertia-Error', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,12 @@ class TenantResource extends Resource
|
||||
{
|
||||
|
||||
return $form->schema([
|
||||
TextInput::make('name')
|
||||
TextInput::make('user.full_name')
|
||||
->label(__('admin.tenants.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->readOnly()
|
||||
->dehydrated(false)
|
||||
->getStateUsing(fn (Tenant $record) => $record->user->full_name),
|
||||
TextInput::make('slug')
|
||||
->label(__('admin.tenants.fields.slug'))
|
||||
->required()
|
||||
@@ -90,7 +92,11 @@ class TenantResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
|
||||
Tables\Columns\TextColumn::make('user.full_name')
|
||||
->label(__('admin.tenants.fields.name'))
|
||||
->searchable()
|
||||
->sortable()
|
||||
->getStateUsing(fn (Tenant $record) => $record->user->full_name),
|
||||
Tables\Columns\TextColumn::make('slug')->searchable(),
|
||||
Tables\Columns\TextColumn::make('contact_email'),
|
||||
Tables\Columns\TextColumn::make('active_reseller_package_id')
|
||||
|
||||
@@ -41,11 +41,11 @@ class AuthenticatedSessionController extends Controller
|
||||
$request->session()->regenerate();
|
||||
|
||||
$user = Auth::user();
|
||||
if ($user && !$user->hasVerifiedEmail()) {
|
||||
return redirect()->route('verification.notice');
|
||||
if ($user && $user->email_verified_at === null) {
|
||||
return Inertia::location(route('verification.notice'));
|
||||
}
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
return Inertia::location(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,18 +15,24 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class MarketingRegisterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the registration page.
|
||||
*/
|
||||
public function create(Request $request, $package_id = null): \Illuminate\View\View
|
||||
public function create(Request $request, $package_id = null): Response
|
||||
{
|
||||
$package = $package_id ? Package::find($package_id) : null;
|
||||
|
||||
return view('marketing.register', [
|
||||
App::setLocale('de');
|
||||
|
||||
return Inertia::render('Auth/Register', [
|
||||
'package' => $package,
|
||||
'privacyHtml' => view('legal.datenschutz')->render(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -38,7 +44,6 @@ class MarketingRegisterController extends Controller
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
@@ -51,7 +56,6 @@ class MarketingRegisterController extends Controller
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'username' => $request->username,
|
||||
'email' => $request->email,
|
||||
'first_name' => $request->first_name,
|
||||
@@ -109,7 +113,7 @@ class MarketingRegisterController extends Controller
|
||||
'active' => true,
|
||||
'price' => 0,
|
||||
]);
|
||||
|
||||
|
||||
PackagePurchase::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
@@ -118,16 +122,16 @@ class MarketingRegisterController extends Controller
|
||||
'purchased_at' => now(),
|
||||
'provider_id' => 'free',
|
||||
]);
|
||||
|
||||
|
||||
$tenant->update(['subscription_status' => 'active']);
|
||||
} else {
|
||||
// Redirect to buy for paid package
|
||||
return redirect()->route('buy.packages', $package->id);
|
||||
return Inertia::location(route('buy.packages', $package->id));
|
||||
}
|
||||
}
|
||||
|
||||
return $user->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard'))
|
||||
: redirect()->route('verification.notice');
|
||||
? Inertia::location(route('dashboard'))
|
||||
: Inertia::location(route('verification.notice'));
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
@@ -36,8 +37,9 @@ class RegisteredUserController extends Controller
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
$fullName = trim($request->first_name . ' ' . $request->last_name);
|
||||
|
||||
$validated = $request->validate([
|
||||
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
@@ -50,23 +52,20 @@ class RegisteredUserController extends Controller
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'username' => $request->username,
|
||||
'email' => $request->email,
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'password' => Hash::make($request->password),
|
||||
'username' => $validated['username'],
|
||||
'email' => $validated['email'],
|
||||
'first_name' => $validated['first_name'],
|
||||
'last_name' => $validated['last_name'],
|
||||
'address' => $validated['address'],
|
||||
'phone' => $validated['phone'],
|
||||
'password' => Hash::make($validated['password']),
|
||||
'privacy_consent_at' => now(), // Neues Feld für Consent (füge Migration hinzu, falls nötig)
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Creating tenant for user ID: ' . $user->id);
|
||||
|
||||
$tenant = Tenant::create([
|
||||
'user_id' => $user->id,
|
||||
'name' => $request->name,
|
||||
'slug' => Str::slug($request->name . '-' . now()->timestamp),
|
||||
'name' => $fullName,
|
||||
'slug' => Str::slug($fullName . '-' . now()->timestamp),
|
||||
'email' => $request->email,
|
||||
'is_active' => true,
|
||||
'is_suspended' => false,
|
||||
@@ -92,8 +91,6 @@ class RegisteredUserController extends Controller
|
||||
]),
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Tenant created with ID: ' . $tenant->id);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
// Send Welcome Email
|
||||
@@ -126,9 +123,7 @@ class RegisteredUserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Logging in user ID: ' . $user->id);
|
||||
Auth::login($user);
|
||||
\Illuminate\Support\Facades\Log::info('User logged in: ' . (Auth::check() ? 'Yes' : 'No'));
|
||||
|
||||
return $user->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard'))
|
||||
|
||||
@@ -22,6 +22,7 @@ use App\Models\Package;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Models\PackagePurchase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class MarketingController extends Controller
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class MarketingController extends Controller
|
||||
['id' => 'premium', 'name' => 'Premium', 'events' => 50, 'price' => 199, 'description' => '50 Events, Support & Custom, Alle Features'],
|
||||
];
|
||||
|
||||
return view('marketing', compact('packages'));
|
||||
return Inertia::render('marketing/Home', compact('packages'));
|
||||
}
|
||||
|
||||
public function contact(Request $request)
|
||||
@@ -57,6 +58,11 @@ class MarketingController extends Controller
|
||||
return redirect()->back()->with('success', 'Nachricht gesendet!');
|
||||
}
|
||||
|
||||
public function contactView()
|
||||
{
|
||||
return Inertia::render('marketing/Kontakt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle package purchase flow.
|
||||
*/
|
||||
@@ -341,7 +347,7 @@ class MarketingController extends Controller
|
||||
return redirect('/admin')->with('success', __('marketing.success.welcome'));
|
||||
}
|
||||
|
||||
return view('marketing.success', compact('packageId'));
|
||||
return Inertia::render('marketing/Success', compact('packageId'));
|
||||
}
|
||||
|
||||
public function blogIndex(Request $request)
|
||||
@@ -377,7 +383,7 @@ class MarketingController extends Controller
|
||||
|
||||
Log::info('Blog Index Debug - Final Posts', ['count' => $posts->count(), 'total' => $posts->total()]);
|
||||
|
||||
return view('marketing.blog', compact('posts'));
|
||||
return Inertia::render('marketing/Blog', compact('posts'));
|
||||
}
|
||||
|
||||
public function blogShow($slug)
|
||||
@@ -394,26 +400,28 @@ class MarketingController extends Controller
|
||||
->whereJsonContains("translations->locale->title->{$locale}", true)
|
||||
->firstOrFail();
|
||||
|
||||
return view('marketing.blog-show', compact('post'));
|
||||
return Inertia::render('marketing/BlogShow', compact('post'));
|
||||
}
|
||||
|
||||
public function packagesIndex()
|
||||
{
|
||||
|
||||
$endcustomerPackages = Package::where('type', 'endcustomer')->orderBy('price')->get();
|
||||
$resellerPackages = Package::where('type', 'reseller')->orderBy('price')->get();
|
||||
$endcustomerPackages = Package::where('type', 'endcustomer')->orderBy('price')->get()->map(function ($p) {
|
||||
return $p->append(['features', 'limits']);
|
||||
});
|
||||
$resellerPackages = Package::where('type', 'reseller')->orderBy('price')->get()->map(function ($p) {
|
||||
return $p->append(['features', 'limits']);
|
||||
});
|
||||
|
||||
return view('marketing.packages', compact('endcustomerPackages', 'resellerPackages'));
|
||||
return Inertia::render('marketing/Packages', compact('endcustomerPackages', 'resellerPackages'));
|
||||
}
|
||||
|
||||
public function occasionsType($locale, $type)
|
||||
{
|
||||
|
||||
$validTypes = ['weddings', 'birthdays', 'corporate-events', 'family-celebrations'];
|
||||
if (!in_array($type, $validTypes)) {
|
||||
abort(404, 'Invalid occasion type');
|
||||
}
|
||||
|
||||
return view('marketing.occasions', ['type' => $type]);
|
||||
return Inertia::render('marketing/Occasions', ['type' => $type]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class ProfileController extends Controller
|
||||
// Authorized via auth middleware
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'username' => ['required', 'string', 'max:255', 'alpha_dash', 'unique:users,username,' . $user->id],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,' . $user->id],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
@@ -40,7 +39,7 @@ class ProfileController extends Controller
|
||||
]);
|
||||
|
||||
$user->update($request->only([
|
||||
'name', 'username', 'email', 'first_name', 'last_name', 'address', 'phone'
|
||||
'username', 'email', 'first_name', 'last_name', 'address', 'phone'
|
||||
]));
|
||||
|
||||
return back()->with('status', 'profile-updated');
|
||||
|
||||
@@ -22,7 +22,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'username',
|
||||
|
||||
Reference in New Issue
Block a user