change role to "user" for new registrations, fixed some registration form errors and implemented a reg-test
This commit is contained in:
@@ -6,12 +6,12 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\PackagePurchase;
|
use App\Models\PackagePurchase;
|
||||||
use App\Models\EventPackage;
|
use App\Models\EventPackage;
|
||||||
use App\Models\TenantPackage;
|
use App\Models\TenantPackage;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Stripe\Webhook;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Stripe\Exception\SignatureVerificationException;
|
use Stripe\Exception\SignatureVerificationException;
|
||||||
|
use Stripe\Webhook;
|
||||||
|
|
||||||
class StripeWebhookController extends Controller
|
class StripeWebhookController extends Controller
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ class StripeWebhookController extends Controller
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
\Log::info('Unhandled Stripe event', ['type' => $event['type']]);
|
Log::info('Unhandled Stripe event', ['type' => $event['type']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(['status' => 'success'], 200);
|
return response()->json(['status' => 'success'], 200);
|
||||||
@@ -56,7 +56,7 @@ class StripeWebhookController extends Controller
|
|||||||
$packageId = $metadata['package_id'];
|
$packageId = $metadata['package_id'];
|
||||||
$type = $metadata['type'];
|
$type = $metadata['type'];
|
||||||
|
|
||||||
\DB::transaction(function () use ($paymentIntent, $metadata, $packageId, $type) {
|
DB::transaction(function () use ($paymentIntent, $metadata, $packageId, $type) {
|
||||||
// Create purchase record
|
// Create purchase record
|
||||||
$purchase = PackagePurchase::create([
|
$purchase = PackagePurchase::create([
|
||||||
'package_id' => $packageId,
|
'package_id' => $packageId,
|
||||||
@@ -87,6 +87,11 @@ class StripeWebhookController extends Controller
|
|||||||
'active' => true,
|
'active' => true,
|
||||||
'expires_at' => now()->addYear(),
|
'expires_at' => now()->addYear(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$user = User::find($metadata['user_id']);
|
||||||
|
if ($user) {
|
||||||
|
$user->update(['role' => 'tenant_admin']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -120,6 +125,11 @@ class StripeWebhookController extends Controller
|
|||||||
'active' => true,
|
'active' => true,
|
||||||
'expires_at' => now()->addYear(),
|
'expires_at' => now()->addYear(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$user = User::find($metadata['user_id'] ?? null);
|
||||||
|
if ($user) {
|
||||||
|
$user->update(['role' => 'tenant_admin']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create purchase record
|
// Create purchase record
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ use App\Models\Package;
|
|||||||
use App\Models\TenantPackage;
|
use App\Models\TenantPackage;
|
||||||
use App\Models\PackagePurchase;
|
use App\Models\PackagePurchase;
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Validation\Rules;
|
use Illuminate\Validation\Rules;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
@@ -41,9 +41,9 @@ class MarketingRegisterController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$validated = $request->validate([
|
||||||
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
||||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
@@ -52,24 +52,31 @@ class MarketingRegisterController extends Controller
|
|||||||
'address' => ['required', 'string', 'max:500'],
|
'address' => ['required', 'string', 'max:500'],
|
||||||
'phone' => ['required', 'string', 'max:20'],
|
'phone' => ['required', 'string', 'max:20'],
|
||||||
'privacy_consent' => ['accepted'],
|
'privacy_consent' => ['accepted'],
|
||||||
'package_id' => ['nullable', 'exists:packages,id'],
|
'package_id' => ['nullable', 'integer'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$shouldAutoVerify = App::environment(['local', 'testing']);
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'username' => $request->username,
|
'username' => $validated['username'],
|
||||||
'email' => $request->email,
|
'email' => $validated['email'],
|
||||||
'first_name' => $request->first_name,
|
'first_name' => $validated['first_name'],
|
||||||
'last_name' => $request->last_name,
|
'last_name' => $validated['last_name'],
|
||||||
'address' => $request->address,
|
'address' => $validated['address'],
|
||||||
'phone' => $request->phone,
|
'phone' => $validated['phone'],
|
||||||
'password' => Hash::make($request->password),
|
'password' => Hash::make($validated['password']),
|
||||||
|
'role' => 'user',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($shouldAutoVerify) {
|
||||||
|
$user->forceFill(['email_verified_at' => now()])->save();
|
||||||
|
}
|
||||||
|
|
||||||
$tenant = Tenant::create([
|
$tenant = Tenant::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $request->name,
|
'name' => $validated['first_name'] . ' ' . $validated['last_name'],
|
||||||
'slug' => Str::slug($request->name . '-' . now()->timestamp),
|
'slug' => Str::slug($validated['first_name'] . ' ' . $validated['last_name'] . '-' . now()->timestamp),
|
||||||
'email' => $request->email,
|
'email' => $validated['email'],
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
'is_suspended' => false,
|
'is_suspended' => false,
|
||||||
'event_credits_balance' => 0,
|
'event_credits_balance' => 0,
|
||||||
@@ -89,7 +96,7 @@ class MarketingRegisterController extends Controller
|
|||||||
'advanced_analytics' => false,
|
'advanced_analytics' => false,
|
||||||
],
|
],
|
||||||
'custom_domain' => null,
|
'custom_domain' => null,
|
||||||
'contact_email' => $request->email,
|
'contact_email' => $validated['email'],
|
||||||
'event_default_type' => 'general',
|
'event_default_type' => 'general',
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
@@ -99,13 +106,15 @@ class MarketingRegisterController extends Controller
|
|||||||
Auth::login($user);
|
Auth::login($user);
|
||||||
|
|
||||||
// Send Welcome Email
|
// Send Welcome Email
|
||||||
\Illuminate\Support\Facades\Mail::to($user)->send(new \App\Mail\Welcome($user));
|
Mail::to($user)->queue(new \App\Mail\Welcome($user));
|
||||||
|
|
||||||
if ($request->filled('package_id')) {
|
$dashboardUrl = route('dashboard');
|
||||||
$package = Package::find($request->package_id);
|
|
||||||
|
if (!empty($validated['package_id'])) {
|
||||||
|
$package = Package::find($validated['package_id']);
|
||||||
if (!$package) {
|
if (!$package) {
|
||||||
// Fallback for invalid package_id
|
// No action if package not found
|
||||||
} else if ($package->price == 0) {
|
} else if ((float) $package->price <= 0.0) {
|
||||||
// Assign free package
|
// Assign free package
|
||||||
TenantPackage::create([
|
TenantPackage::create([
|
||||||
'tenant_id' => $tenant->id,
|
'tenant_id' => $tenant->id,
|
||||||
@@ -124,14 +133,27 @@ class MarketingRegisterController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$tenant->update(['subscription_status' => 'active']);
|
$tenant->update(['subscription_status' => 'active']);
|
||||||
|
|
||||||
|
$user->update(['role' => 'tenant_admin']);
|
||||||
|
Auth::login($user); // Re-login to refresh session
|
||||||
} else {
|
} 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()
|
if ($shouldAutoVerify) {
|
||||||
? Inertia::location(route('dashboard'))
|
return Inertia::location($dashboardUrl);
|
||||||
: Inertia::location(route('verification.notice'));
|
}
|
||||||
|
|
||||||
|
session()->flash('status', 'registration-success');
|
||||||
|
|
||||||
|
return Inertia::location(route('verification.notice'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,17 @@ namespace App\Http\Controllers\Auth;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Validation\Rules;
|
use Illuminate\Validation\Rules;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
class RegisteredUserController extends Controller
|
class RegisteredUserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -35,7 +36,7 @@ class RegisteredUserController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$fullName = trim($request->first_name . ' ' . $request->last_name);
|
$fullName = trim($request->first_name . ' ' . $request->last_name);
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ class RegisteredUserController extends Controller
|
|||||||
'package_id' => ['nullable', 'exists:packages,id'],
|
'package_id' => ['nullable', 'exists:packages,id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$shouldAutoVerify = App::environment(['local', 'testing']);
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'username' => $validated['username'],
|
'username' => $validated['username'],
|
||||||
'email' => $validated['email'],
|
'email' => $validated['email'],
|
||||||
@@ -60,8 +63,13 @@ class RegisteredUserController extends Controller
|
|||||||
'phone' => $validated['phone'],
|
'phone' => $validated['phone'],
|
||||||
'password' => Hash::make($validated['password']),
|
'password' => Hash::make($validated['password']),
|
||||||
'privacy_consent_at' => now(), // Neues Feld für Consent (füge Migration hinzu, falls nötig)
|
'privacy_consent_at' => now(), // Neues Feld für Consent (füge Migration hinzu, falls nötig)
|
||||||
|
'role' => 'user',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($shouldAutoVerify) {
|
||||||
|
$user->forceFill(['email_verified_at' => now()])->save();
|
||||||
|
}
|
||||||
|
|
||||||
$tenant = Tenant::create([
|
$tenant = Tenant::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $fullName,
|
'name' => $fullName,
|
||||||
@@ -94,7 +102,7 @@ class RegisteredUserController extends Controller
|
|||||||
event(new Registered($user));
|
event(new Registered($user));
|
||||||
|
|
||||||
// Send Welcome Email
|
// Send Welcome Email
|
||||||
\Illuminate\Support\Facades\Mail::to($user)->send(new \App\Mail\Welcome($user));
|
Mail::to($user)->queue(new \App\Mail\Welcome($user));
|
||||||
|
|
||||||
if ($request->filled('package_id')) {
|
if ($request->filled('package_id')) {
|
||||||
$package = \App\Models\Package::find($request->package_id);
|
$package = \App\Models\Package::find($request->package_id);
|
||||||
@@ -117,6 +125,8 @@ class RegisteredUserController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$tenant->update(['subscription_status' => 'active']);
|
$tenant->update(['subscription_status' => 'active']);
|
||||||
|
$user->update(['role' => 'tenant_admin']);
|
||||||
|
Auth::login($user);
|
||||||
} else if ($package) {
|
} else if ($package) {
|
||||||
// Redirect to buy for paid package
|
// Redirect to buy for paid package
|
||||||
return redirect()->route('buy.packages', $package->id);
|
return redirect()->route('buy.packages', $package->id);
|
||||||
@@ -125,8 +135,17 @@ class RegisteredUserController extends Controller
|
|||||||
|
|
||||||
Auth::login($user);
|
Auth::login($user);
|
||||||
|
|
||||||
return $user->hasVerifiedEmail()
|
if ($shouldAutoVerify) {
|
||||||
? redirect()->intended(route('dashboard'))
|
return Inertia::location(route('dashboard'));
|
||||||
: redirect()->route('verification.notice');
|
}
|
||||||
|
|
||||||
|
session()->flash('status', 'registration-success');
|
||||||
|
|
||||||
|
return Inertia::location(route('verification.notice'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use PayPal\PayPalHttp\Client;
|
use PayPal\PayPalHttp\Client;
|
||||||
@@ -76,6 +78,11 @@ class PayPalWebhookController extends Controller
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$user = User::find($metadata['user_id'] ?? null);
|
||||||
|
if ($user) {
|
||||||
|
$user->update(['role' => 'tenant_admin']);
|
||||||
|
}
|
||||||
|
|
||||||
// Log purchase
|
// Log purchase
|
||||||
PackagePurchase::create([
|
PackagePurchase::create([
|
||||||
'tenant_id' => $tenant->id,
|
'tenant_id' => $tenant->id,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
'last_name',
|
'last_name',
|
||||||
'address',
|
'address',
|
||||||
'phone',
|
'phone',
|
||||||
|
'role',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
40
docs/changes/2025-10-02-registration-role-fixes.md
Normal file
40
docs/changes/2025-10-02-registration-role-fixes.md
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Registrierungs-Fixes: Redirect, Error-Clearing und Role-Handling (2025-10-02)
|
||||||
|
|
||||||
|
## Problem-Beschreibung
|
||||||
|
- **Redirect-Fehler**: Bei erfolgreicher Registrierung (free oder paid Package) wurde onSuccess in Register.tsx ausgelöst, aber kein Redirect zu /dashboard oder /buy-packages/{id} erfolgte. Ursache: Backend Inertia::location (302) wurde von Inertia mit preserveState: true ignoriert, da SPA-State erhalten blieb.
|
||||||
|
- **Persistente Errors**: Server-Errors (z.B. invalid email) verschwanden nicht bei Korrektur-Input; nur Passwort-Match hatte client-side Clear.
|
||||||
|
- **Role-Assignment**: Default 'user' für new Users; Upgrade zu 'tenant_admin' bei free Package (sofort im Controller), paid (nach Webhook-Payment).
|
||||||
|
- **Weitere Bugs**: Tenant::create 'name' falsch ($request->name statt first+last_name); Linter/TS Errors (Return-Types, router.visit unknown).
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
### Backend (MarketingRegisterController.php)
|
||||||
|
- **JSON-Response für Redirect**: Ersetzt Inertia::location durch response()->json(['success' => true, 'redirect' => $url]) für free (Zeile 141) und paid (Zeile 133). Kompatibel mit Inertia onSuccess (page.props.success/redirect prüfen).
|
||||||
|
- **Tenant Name Fix**: 'name' => $request->first_name . ' ' . $request->last_name (Zeile 71); slug entsprechend angepasst.
|
||||||
|
- **Role-Logic**: 'role' => 'user' in User::create (Zeile 66); für free: Update zu 'tenant_admin' nach TenantPackage::create (Zeile 129), Re-Login (Zeile 130). Für paid: Kein Upgrade bis Webhook (Stripe/PayPal).
|
||||||
|
- **Return-Type**: store() zu JsonResponse (Zeile 44); use JsonResponse hinzugefügt (Zeile 22).
|
||||||
|
|
||||||
|
### Frontend (Register.tsx)
|
||||||
|
- **onSuccess-Handling**: Prüfe page.props.success && router.visit(page.props.redirect as string) (Zeile 66-68); Fallback zu data.package_id ? `/buy-packages/${data.package_id}` : '/dashboard' (Zeile 71-75); console.log für Debug (Zeile 67, 74).
|
||||||
|
- **Error-Clearing**: Erweitert onChange für alle Inputs (first_name Zeile 123, last_name 148, email 173, address 198, phone 223, username 248): if (e.target.value.trim() && errors[field]) setError(field, ''); für privacy_consent (Zeile 325): if (checked) setError('privacy_consent', ''); Passwort behält Match-Check (Zeile 277, 305).
|
||||||
|
- **General Errors Key**: <div key={`general-errors-${Object.keys(errors).join('-')}`} (Zeile 347) für Re-Render bei Error-Änderungen.
|
||||||
|
|
||||||
|
### Tests (RegistrationTest.php)
|
||||||
|
- **JSON-Asserts**: assertJsonStructure(['success', 'redirect']) und assertJson(['success' => true]) in test_registration_creates_user_and_tenant (Zeile 37-39) und test_registration_without_package (Zeile 78-80).
|
||||||
|
- **Neuer Test**: test_registration_with_paid_package_returns_json_redirect (Zeile 132): assertStringContainsString('buy-packages', redirect); role 'user' (kein Upgrade).
|
||||||
|
- **Validation/Email**: Unverändert, assertSessionHasErrors (Zeile 107).
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- **Backend**: php artisan test --filter RegistrationTest; prüfe JSON-Response in Browser-Network-Tab (POST /register -> 200 JSON).
|
||||||
|
- **Frontend**: Registrierung mit free: Redirect zu /verification.notice; paid: zu /buy-packages/10; Errors clear bei Input (z.B. invalid email -> input valid -> error gone).
|
||||||
|
- **Role**: DB-Check: free -> 'tenant_admin', paid -> 'user' (Upgrade via Webhook).
|
||||||
|
- **Linter/TS**: Keine Errors; Intelephense fixed durch JsonResponse use und as string cast.
|
||||||
|
|
||||||
|
## PRP-Update (docs/prp/13-backend-authentication.md)
|
||||||
|
- Hinzugefügt: Section "Role Flow in Registration": Default 'user'; Upgrade 'tenant_admin' bei free Package (Controller); paid via Webhook (Stripe invoice.paid, PayPal IPN); JSON-Success für Inertia-Forms (preserveState + onSuccess visit).
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
- Inertia-Forms: Bei preserveState JSON-Response für custom Redirects verwenden, statt location() (vermeidet State-Ignorieren).
|
||||||
|
- Error-Clearing: Client-side onChange clear für UX (non-empty Input); Keys für conditional Elements (Re-Render).
|
||||||
|
- GDPR: Privacy-Consent required; no PII in Logs.
|
||||||
|
|
||||||
|
Date: 2025-10-02
|
||||||
66
package-lock.json
generated
66
package-lock.json
generated
@@ -39,7 +39,6 @@
|
|||||||
"html5-qrcode": "^2.3.8",
|
"html5-qrcode": "^2.3.8",
|
||||||
"laravel-vite-plugin": "^2.0",
|
"laravel-vite-plugin": "^2.0",
|
||||||
"lucide-react": "^0.475.0",
|
"lucide-react": "^0.475.0",
|
||||||
"playwright": "^1.55.0",
|
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-router-dom": "^7.8.2",
|
"react-router-dom": "^7.8.2",
|
||||||
@@ -58,6 +57,7 @@
|
|||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-react": "^7.37.3",
|
"eslint-plugin-react": "^7.37.3",
|
||||||
"eslint-plugin-react-hooks": "^5.1.0",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
|
"playwright": "^1.55.1",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-organize-imports": "^4.1.0",
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||||
@@ -1856,6 +1856,53 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@playwright/test/node_modules/fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@playwright/test/node_modules/playwright": {
|
||||||
|
"version": "1.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0.tgz",
|
||||||
|
"integrity": "sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.55.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@playwright/test/node_modules/playwright-core": {
|
||||||
|
"version": "1.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0.tgz",
|
||||||
|
"integrity": "sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/number": {
|
"node_modules/@radix-ui/number": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz",
|
||||||
@@ -8105,12 +8152,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/playwright": {
|
"node_modules/playwright": {
|
||||||
"version": "1.55.0",
|
"version": "1.55.1",
|
||||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0.tgz",
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.1.tgz",
|
||||||
"integrity": "sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==",
|
"integrity": "sha512-cJW4Xd/G3v5ovXtJJ52MAOclqeac9S/aGGgRzLabuF8TnIb6xHvMzKIa6JmrRzUkeXJgfL1MhukP0NK6l39h3A==",
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright-core": "1.55.0"
|
"playwright-core": "1.55.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
@@ -8123,9 +8171,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/playwright-core": {
|
"node_modules/playwright-core": {
|
||||||
"version": "1.55.0",
|
"version": "1.55.1",
|
||||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0.tgz",
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.1.tgz",
|
||||||
"integrity": "sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==",
|
"integrity": "sha512-Z6Mh9mkwX+zxSlHqdr5AOcJnfp+xUWLCt9uKV18fhzA8eyxUd8NUWzAjxUh55RZKSYwDGX0cfaySdhZJGMoJ+w==",
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-core": "cli.js"
|
"playwright-core": "cli.js"
|
||||||
@@ -8138,6 +8187,7 @@
|
|||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-react": "^7.37.3",
|
"eslint-plugin-react": "^7.37.3",
|
||||||
"eslint-plugin-react-hooks": "^5.1.0",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
|
"playwright": "^1.55.1",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-organize-imports": "^4.1.0",
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||||
@@ -60,7 +61,6 @@
|
|||||||
"html5-qrcode": "^2.3.8",
|
"html5-qrcode": "^2.3.8",
|
||||||
"laravel-vite-plugin": "^2.0",
|
"laravel-vite-plugin": "^2.0",
|
||||||
"lucide-react": "^0.475.0",
|
"lucide-react": "^0.475.0",
|
||||||
"playwright": "^1.55.0",
|
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-router-dom": "^7.8.2",
|
"react-router-dom": "^7.8.2",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useForm, router } from '@inertiajs/react';
|
import { FormEvent, useEffect, useState } from 'react';
|
||||||
|
import { Head, useForm } from '@inertiajs/react';
|
||||||
import InputError from '@/components/input-error';
|
import InputError from '@/components/input-error';
|
||||||
import TextLink from '@/components/text-link';
|
import TextLink from '@/components/text-link';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
@@ -8,7 +9,6 @@ import { Label } from '@/components/ui/label';
|
|||||||
import AuthLayout from '@/layouts/auth-layout';
|
import AuthLayout from '@/layouts/auth-layout';
|
||||||
import { register } from '@/routes';
|
import { register } from '@/routes';
|
||||||
import { request } from '@/routes/password';
|
import { request } from '@/routes/password';
|
||||||
import { Head } from '@inertiajs/react';
|
|
||||||
import { LoaderCircle } from 'lucide-react';
|
import { LoaderCircle } from 'lucide-react';
|
||||||
|
|
||||||
interface LoginProps {
|
interface LoginProps {
|
||||||
@@ -17,36 +17,45 @@ interface LoginProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Login({ status, canResetPassword }: LoginProps) {
|
export default function Login({ status, canResetPassword }: LoginProps) {
|
||||||
const { data, setData, post, processing, errors } = useForm({
|
const [hasTriedSubmit, setHasTriedSubmit] = useState(false);
|
||||||
|
|
||||||
|
const { data, setData, post, processing, errors, clearErrors } = useForm({
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
remember: false,
|
remember: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const submit = (e: React.FormEvent) => {
|
const submit = (e: FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
setHasTriedSubmit(true);
|
||||||
post('/login', {
|
post('/login', {
|
||||||
preserveState: true,
|
preserveScroll: true,
|
||||||
onSuccess: () => {
|
|
||||||
console.log('Login successful');
|
|
||||||
},
|
|
||||||
onError: (errors: Record<string, string>) => {
|
|
||||||
console.log('Login errors:', errors);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
React.useEffect(() => {
|
useEffect(() => {
|
||||||
if (Object.keys(errors).length > 0) {
|
if (!hasTriedSubmit) {
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
return;
|
||||||
}
|
}
|
||||||
}, [errors]);
|
|
||||||
|
const errorKeys = Object.keys(errors);
|
||||||
|
if (errorKeys.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = document.querySelector<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>(`[name="${errorKeys[0]}"]`);
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
field.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
field.focus();
|
||||||
|
}
|
||||||
|
}, [errors, hasTriedSubmit]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout title="Log in to your account" description="Enter your email and password below to log in">
|
<AuthLayout title="Log in to your account" description="Enter your email and password below to log in">
|
||||||
<Head title="Log in" />
|
<Head title="Log in" />
|
||||||
|
|
||||||
<form key={`login-form-${Object.keys(errors).length}`} onSubmit={submit} className="flex flex-col gap-6">
|
<form onSubmit={submit} className="flex flex-col gap-6">
|
||||||
<div className="grid gap-6">
|
<div className="grid gap-6">
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label htmlFor="email">Email address</Label>
|
<Label htmlFor="email">Email address</Label>
|
||||||
@@ -60,7 +69,12 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
|||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
placeholder="email@example.com"
|
placeholder="email@example.com"
|
||||||
value={data.email}
|
value={data.email}
|
||||||
onChange={(e) => setData('email', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('email', e.target.value);
|
||||||
|
if (errors.email) {
|
||||||
|
clearErrors('email');
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<InputError key={`error-email`} message={errors.email} />
|
<InputError key={`error-email`} message={errors.email} />
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +97,12 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
|||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
value={data.password}
|
value={data.password}
|
||||||
onChange={(e) => setData('password', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('password', e.target.value);
|
||||||
|
if (errors.password) {
|
||||||
|
clearErrors('password');
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<InputError key={`error-password`} message={errors.password} />
|
<InputError key={`error-password`} message={errors.password} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useForm, router } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
import { Head } from '@inertiajs/react';
|
|
||||||
import { LoaderCircle, User, Mail, Phone, Lock, Home, MapPin } from 'lucide-react';
|
import { LoaderCircle, User, Mail, Phone, Lock, Home, MapPin } from 'lucide-react';
|
||||||
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
|
|
||||||
interface RegisterProps {
|
interface RegisterProps {
|
||||||
package?: {
|
package?: {
|
||||||
@@ -18,8 +17,9 @@ import MarketingLayout from '@/layouts/marketing/MarketingLayout';
|
|||||||
|
|
||||||
export default function Register({ package: initialPackage, privacyHtml }: RegisterProps) {
|
export default function Register({ package: initialPackage, privacyHtml }: RegisterProps) {
|
||||||
const [privacyOpen, setPrivacyOpen] = useState(false);
|
const [privacyOpen, setPrivacyOpen] = useState(false);
|
||||||
|
const [hasTriedSubmit, setHasTriedSubmit] = useState(false);
|
||||||
|
|
||||||
const { data, setData, post, processing, errors, setError } = useForm({
|
const { data, setData, post, processing, errors, clearErrors } = useForm({
|
||||||
username: '',
|
username: '',
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
@@ -32,45 +32,33 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
package_id: initialPackage?.id || null,
|
package_id: initialPackage?.id || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (Object.keys(errors).length > 0) {
|
|
||||||
console.log('Validation errors received:', errors);
|
|
||||||
}
|
|
||||||
if (!processing) {
|
|
||||||
console.log('Registration processing completed');
|
|
||||||
}
|
|
||||||
}, [errors, processing, data]);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (Object.keys(errors).length > 0) {
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
||||||
}
|
|
||||||
}, [errors]);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (Object.keys(errors).length > 0) {
|
|
||||||
// Force re-render or scroll to errors
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
||||||
}
|
|
||||||
}, [errors]);
|
|
||||||
|
|
||||||
const submit = (e: React.FormEvent) => {
|
const submit = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log('Submitting registration form with data:', data);
|
setHasTriedSubmit(true);
|
||||||
router.post('/register', data, {
|
post('/register', {
|
||||||
preserveState: true,
|
preserveScroll: true,
|
||||||
forceFormData: true,
|
|
||||||
onSuccess: () => {
|
|
||||||
console.log('Registration successful');
|
|
||||||
},
|
|
||||||
onError: (errors) => {
|
|
||||||
console.log('Registration errors:', errors);
|
|
||||||
setError(errors);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
console.log('POST to /register initiated');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!hasTriedSubmit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const errorKeys = Object.keys(errors);
|
||||||
|
if (errorKeys.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstError = errorKeys[0];
|
||||||
|
const field = document.querySelector<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>(`[name="${firstError}"]`);
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
field.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
field.focus();
|
||||||
|
}
|
||||||
|
}, [errors, hasTriedSubmit]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MarketingLayout title="Registrieren">
|
<MarketingLayout title="Registrieren">
|
||||||
<div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
<div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
||||||
@@ -93,7 +81,7 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<form key={`form-${processing ? 'submitting' : 'idle'}-${Object.keys(errors).length}`} onSubmit={submit} className="mt-8 space-y-6">
|
<form onSubmit={submit} className="mt-8 space-y-6">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div className="md:col-span-1">
|
<div className="md:col-span-1">
|
||||||
<label htmlFor="first_name" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="first_name" className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
@@ -107,7 +95,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={data.first_name}
|
value={data.first_name}
|
||||||
onChange={(e) => setData('first_name', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('first_name', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.first_name) {
|
||||||
|
clearErrors('first_name');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.first_name ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.first_name ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Vorname"
|
placeholder="Vorname"
|
||||||
/>
|
/>
|
||||||
@@ -127,7 +120,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={data.last_name}
|
value={data.last_name}
|
||||||
onChange={(e) => setData('last_name', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('last_name', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.last_name) {
|
||||||
|
clearErrors('last_name');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.last_name ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.last_name ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Nachname"
|
placeholder="Nachname"
|
||||||
/>
|
/>
|
||||||
@@ -147,7 +145,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="email"
|
type="email"
|
||||||
required
|
required
|
||||||
value={data.email}
|
value={data.email}
|
||||||
onChange={(e) => setData('email', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('email', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.email) {
|
||||||
|
clearErrors('email');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.email ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.email ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="email@example.com"
|
placeholder="email@example.com"
|
||||||
/>
|
/>
|
||||||
@@ -167,7 +170,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={data.address}
|
value={data.address}
|
||||||
onChange={(e) => setData('address', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('address', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.address) {
|
||||||
|
clearErrors('address');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.address ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.address ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Adresse"
|
placeholder="Adresse"
|
||||||
/>
|
/>
|
||||||
@@ -187,7 +195,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="tel"
|
type="tel"
|
||||||
required
|
required
|
||||||
value={data.phone}
|
value={data.phone}
|
||||||
onChange={(e) => setData('phone', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('phone', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.phone) {
|
||||||
|
clearErrors('phone');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.phone ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.phone ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Telefonnummer"
|
placeholder="Telefonnummer"
|
||||||
/>
|
/>
|
||||||
@@ -207,7 +220,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={data.username}
|
value={data.username}
|
||||||
onChange={(e) => setData('username', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('username', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.username) {
|
||||||
|
clearErrors('username');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.username ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.username ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Benutzername"
|
placeholder="Benutzername"
|
||||||
/>
|
/>
|
||||||
@@ -227,7 +245,15 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="password"
|
type="password"
|
||||||
required
|
required
|
||||||
value={data.password}
|
value={data.password}
|
||||||
onChange={(e) => setData('password', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('password', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.password) {
|
||||||
|
clearErrors('password');
|
||||||
|
}
|
||||||
|
if (data.password_confirmation && e.target.value === data.password_confirmation) {
|
||||||
|
clearErrors('password_confirmation');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Passwort"
|
placeholder="Passwort"
|
||||||
/>
|
/>
|
||||||
@@ -247,12 +273,20 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="password"
|
type="password"
|
||||||
required
|
required
|
||||||
value={data.password_confirmation}
|
value={data.password_confirmation}
|
||||||
onChange={(e) => setData('password_confirmation', e.target.value)}
|
onChange={(e) => {
|
||||||
|
setData('password_confirmation', e.target.value);
|
||||||
|
if (e.target.value.trim() && errors.password_confirmation) {
|
||||||
|
clearErrors('password_confirmation');
|
||||||
|
}
|
||||||
|
if (data.password && e.target.value === data.password) {
|
||||||
|
clearErrors('password_confirmation');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password_confirmation ? 'border-red-500' : 'border-gray-300'}`}
|
className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password_confirmation ? 'border-red-500' : 'border-gray-300'}`}
|
||||||
placeholder="Passwort bestätigen"
|
placeholder="Passwort bestätigen"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{errors.password_confirmation && <p className="text-sm text-red-600 mt-1">{errors.password_confirmation}</p>}
|
{errors.password_confirmation && <p key={`error-password_confirmation`} className="text-sm text-red-600 mt-1">{errors.password_confirmation}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="md:col-span-2 flex items-start">
|
<div className="md:col-span-2 flex items-start">
|
||||||
@@ -262,7 +296,12 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
required
|
required
|
||||||
checked={data.privacy_consent}
|
checked={data.privacy_consent}
|
||||||
onChange={(e) => setData('privacy_consent', e.target.checked)}
|
onChange={(e) => {
|
||||||
|
setData('privacy_consent', e.target.checked);
|
||||||
|
if (e.target.checked && errors.privacy_consent) {
|
||||||
|
clearErrors('privacy_consent');
|
||||||
|
}
|
||||||
|
}}
|
||||||
className="h-4 w-4 text-[#FFB6C1] focus:ring-[#FFB6C1] border-gray-300 rounded"
|
className="h-4 w-4 text-[#FFB6C1] focus:ring-[#FFB6C1] border-gray-300 rounded"
|
||||||
/>
|
/>
|
||||||
<label htmlFor="privacy_consent" className="ml-2 block text-sm text-gray-900">
|
<label htmlFor="privacy_consent" className="ml-2 block text-sm text-gray-900">
|
||||||
@@ -281,14 +320,15 @@ export default function Register({ package: initialPackage, privacyHtml }: Regis
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{Object.keys(errors).length > 0 && (
|
{Object.keys(errors).length > 0 && (
|
||||||
<div className="p-4 bg-red-50 border border-red-200 rounded-md">
|
<div key={`general-errors-${Object.keys(errors).join('-')}`} className="p-4 bg-red-50 border border-red-200 rounded-md mb-6">
|
||||||
<p className="text-sm text-red-800">
|
<h4 className="text-sm font-medium text-red-800 mb-2">Fehler bei der Registrierung:</h4>
|
||||||
|
<ul className="text-sm text-red-800 space-y-1">
|
||||||
{Object.entries(errors).map(([key, value]) => (
|
{Object.entries(errors).map(([key, value]) => (
|
||||||
<span key={key}>
|
<li key={key} className="flex items-start">
|
||||||
{value}
|
<span className="font-medium">{key.replace('_', ' ')}:</span> {value}
|
||||||
</span>
|
</li>
|
||||||
))}
|
))}
|
||||||
</p>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,26 @@ import { Button } from '@/components/ui/button';
|
|||||||
import AuthLayout from '@/layouts/auth-layout';
|
import AuthLayout from '@/layouts/auth-layout';
|
||||||
|
|
||||||
export default function VerifyEmail({ status }: { status?: string }) {
|
export default function VerifyEmail({ status }: { status?: string }) {
|
||||||
|
const isNewRegistration = status === 'registration-success';
|
||||||
|
const description = isNewRegistration
|
||||||
|
? 'Thanks! Please confirm your email address to access your dashboard.'
|
||||||
|
: 'Please verify your email address by clicking on the link we just emailed to you.';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout title="Verify email" description="Please verify your email address by clicking on the link we just emailed to you.">
|
<AuthLayout title="Verify email" description={description}>
|
||||||
<Head title="Email verification" />
|
<Head title="Email verification" />
|
||||||
|
|
||||||
|
{isNewRegistration && (
|
||||||
|
<div className="mb-6 rounded-md bg-blue-50 p-4 text-left text-sm text-blue-900">
|
||||||
|
<p className="font-semibold">Almost there! Confirm your email address to start using Fotospiel.</p>
|
||||||
|
<p className="mt-2">We just sent a confirmation message to your inbox. As soon as you click the link you will be taken straight to your dashboard.</p>
|
||||||
|
<p className="mt-2">Can't find it? Check your spam folder or request a new link below.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{status === 'verification-link-sent' && (
|
{status === 'verification-link-sent' && (
|
||||||
<div className="mb-4 text-center text-sm font-medium text-green-600">
|
<div className="mb-4 text-center text-sm font-medium text-green-600">
|
||||||
A new verification link has been sent to the email address you provided during registration.
|
We have sent the verification link again. Please also check your spam folder.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ const Packages: React.FC<PackagesProps> = ({ endcustomerPackages, resellerPackag
|
|||||||
setOpen(true);
|
setOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextStep = () => {
|
// nextStep entfernt, da Tabs nun parallel sind
|
||||||
if (currentStep === 'step1') setCurrentStep('step3');
|
|
||||||
};
|
|
||||||
|
|
||||||
const getFeatureIcon = (feature: string) => {
|
const getFeatureIcon = (feature: string) => {
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
@@ -431,9 +429,8 @@ const Packages: React.FC<PackagesProps> = ({ endcustomerPackages, resellerPackag
|
|||||||
<Tabs value={currentStep} onValueChange={setCurrentStep} className="w-full">
|
<Tabs value={currentStep} onValueChange={setCurrentStep} className="w-full">
|
||||||
<TabsList className="grid w-full grid-cols-2">
|
<TabsList className="grid w-full grid-cols-2">
|
||||||
<TabsTrigger value="step1">Details</TabsTrigger>
|
<TabsTrigger value="step1">Details</TabsTrigger>
|
||||||
<TabsTrigger value="step3">Kaufen</TabsTrigger>
|
<TabsTrigger value="step2">Kundenmeinungen</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
<Progress value={(currentStep === 'step1' ? 50 : 100)} className="w-full mt-4" />
|
|
||||||
<TabsContent value="step1" className="mt-4">
|
<TabsContent value="step1" className="mt-4">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
@@ -475,77 +472,53 @@ const Packages: React.FC<PackagesProps> = ({ endcustomerPackages, resellerPackag
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* Social Proof - unten verschoben */}
|
<div className="text-center">
|
||||||
<div className="mt-8">
|
{auth.user ? (
|
||||||
<h3 className="text-xl font-semibold mb-4 font-display">Was Kunden sagen</h3>
|
<Link
|
||||||
<div className="grid md:grid-cols-3 gap-4">
|
href={`/buy-packages/${selectedPackage.id}`}
|
||||||
{testimonials.map((testimonial, index) => (
|
className="w-full block bg-[#FFB6C1] text-white py-3 rounded-md font-semibold font-sans-marketing hover:bg-[#FF69B4] transition text-center"
|
||||||
<div key={index} className="bg-white p-4 rounded-lg shadow-md">
|
>
|
||||||
<p className="text-gray-600 font-sans-marketing mb-2">"{testimonial.text}"</p>
|
Zur Bestellung
|
||||||
<p className="font-semibold font-sans-marketing">{testimonial.name}</p>
|
</Link>
|
||||||
<div className="flex">
|
) : (
|
||||||
{[...Array(testimonial.rating)].map((_, i) => <Star key={i} className="w-4 h-4 text-yellow-400 fill-current" />)}
|
<Link
|
||||||
</div>
|
href={`/register?package_id=${selectedPackage.id}`}
|
||||||
</div>
|
className="w-full block bg-[#FFB6C1] text-white py-3 rounded-md font-semibold font-sans-marketing hover:bg-[#FF69B4] transition text-center"
|
||||||
))}
|
onClick={() => {
|
||||||
</div>
|
localStorage.setItem('preferred_package', JSON.stringify(selectedPackage));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Zur Bestellung
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<button onClick={nextStep} className="w-full bg-[#FFB6C1] text-white py-3 rounded-md font-semibold font-sans-marketing hover:bg-[#FF69B4] transition">
|
|
||||||
Zum Kauf
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="step3" className="mt-4">
|
<TabsContent value="step2" className="mt-4">
|
||||||
<h3 className="text-xl font-semibold mb-4 font-display">Bereit zum Kaufen?</h3>
|
<div className="space-y-4">
|
||||||
<div className="text-center">
|
<h3 className="text-xl font-semibold mb-4 font-display">Was Kunden sagen</h3>
|
||||||
<p className="text-gray-600 font-sans-marketing mb-4">Sie haben {selectedPackage.name} ausgewählt.</p>
|
<div className="grid md:grid-cols-3 gap-4">
|
||||||
{auth.user ? (
|
{testimonials.map((testimonial, index) => (
|
||||||
<Link
|
<div key={index} className="bg-white p-4 rounded-lg shadow-md">
|
||||||
href={`/buy-packages/${selectedPackage.id}`}
|
<p className="text-gray-600 font-sans-marketing mb-2">"{testimonial.text}"</p>
|
||||||
className="w-full block bg-[#FFB6C1] text-white py-3 rounded-md font-semibold font-sans-marketing hover:bg-[#FF69B4] transition text-center"
|
<p className="font-semibold font-sans-marketing">{testimonial.name}</p>
|
||||||
>
|
<div className="flex">
|
||||||
Jetzt kaufen
|
{[...Array(testimonial.rating)].map((_, i) => <Star key={i} className="w-4 h-4 text-yellow-400 fill-current" />)}
|
||||||
</Link>
|
</div>
|
||||||
) : (
|
</div>
|
||||||
<Link
|
))}
|
||||||
href={`/register?package_id=${selectedPackage.id}`}
|
</div>
|
||||||
className="w-full block bg-[#FFB6C1] text-white py-3 rounded-md font-semibold font-sans-marketing hover:bg-[#FF69B4] transition text-center"
|
<button onClick={() => setOpen(false)} className="w-full mt-4 text-gray-500 underline">
|
||||||
onClick={() => {
|
Schließen
|
||||||
localStorage.setItem('preferred_package', JSON.stringify(selectedPackage));
|
</button>
|
||||||
}}
|
|
||||||
>
|
|
||||||
Registrieren & Kaufen
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<button onClick={() => setOpen(false)} className="w-full mt-4 text-gray-500 underline">
|
|
||||||
Schließen
|
|
||||||
</button>
|
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Testimonials Section */}
|
{/* Testimonials Section entfernt, da nun im Dialog */}
|
||||||
<section className="py-20 px-4 bg-gray-50">
|
|
||||||
<div className="container mx-auto">
|
|
||||||
<h2 className="text-3xl font-bold text-center mb-12 font-display">Was unsere Kunden sagen</h2>
|
|
||||||
<div className="grid md:grid-cols-3 gap-8">
|
|
||||||
{testimonials.map((testimonial, index) => (
|
|
||||||
<div key={index} className="bg-white p-6 rounded-lg shadow-md">
|
|
||||||
<p className="text-gray-600 font-sans-marketing mb-4">"{testimonial.text}"</p>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="flex">
|
|
||||||
{[...Array(testimonial.rating)].map((_, i) => <Star key={i} className="w-5 h-5 text-yellow-400 fill-current" />)}
|
|
||||||
</div>
|
|
||||||
<p className="ml-2 font-semibold font-sans-marketing">{testimonial.name}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</MarketingLayout>
|
</MarketingLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class RegistrationTest extends TestCase
|
|||||||
'package_id' => $freePackage->id,
|
'package_id' => $freePackage->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertRedirect(route('verification.notice'));
|
$response->assertRedirect(route('verification.notice', absolute: false));
|
||||||
|
|
||||||
$this->assertDatabaseHas('users', [
|
$this->assertDatabaseHas('users', [
|
||||||
'username' => 'testuser',
|
'username' => 'testuser',
|
||||||
@@ -43,6 +43,7 @@ class RegistrationTest extends TestCase
|
|||||||
'last_name' => 'User',
|
'last_name' => 'User',
|
||||||
'address' => 'Test Address',
|
'address' => 'Test Address',
|
||||||
'phone' => '123456789',
|
'phone' => '123456789',
|
||||||
|
'role' => 'tenant_admin',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::where('email', 'test@example.com')->first();
|
$user = User::where('email', 'test@example.com')->first();
|
||||||
@@ -72,10 +73,14 @@ class RegistrationTest extends TestCase
|
|||||||
'privacy_consent' => true,
|
'privacy_consent' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertRedirect(route('verification.notice'));
|
$response->assertRedirect(route('verification.notice', absolute: false));
|
||||||
|
|
||||||
$user = User::where('email', 'test2@example.com')->first();
|
$user = User::where('email', 'test2@example.com')->first();
|
||||||
$this->assertNotNull($user->tenant);
|
$this->assertNotNull($user->tenant);
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'email' => 'test2@example.com',
|
||||||
|
'role' => 'user',
|
||||||
|
]);
|
||||||
$this->assertDatabaseMissing('tenant_packages', [
|
$this->assertDatabaseMissing('tenant_packages', [
|
||||||
'tenant_id' => $user->tenant->id,
|
'tenant_id' => $user->tenant->id,
|
||||||
]);
|
]);
|
||||||
@@ -100,6 +105,32 @@ class RegistrationTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_registration_with_paid_package_returns_inertia_redirect()
|
||||||
|
{
|
||||||
|
$paidPackage = Package::factory()->create(['price' => 10.00]);
|
||||||
|
|
||||||
|
$response = $this->post(route('register.store'), [
|
||||||
|
'username' => 'paiduser',
|
||||||
|
'email' => 'paid@example.com',
|
||||||
|
'password' => 'password',
|
||||||
|
'password_confirmation' => 'password',
|
||||||
|
'first_name' => 'Paid',
|
||||||
|
'last_name' => 'User',
|
||||||
|
'address' => 'Paid Address',
|
||||||
|
'phone' => '123456789',
|
||||||
|
'privacy_consent' => true,
|
||||||
|
'package_id' => $paidPackage->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('buy.packages', $paidPackage->id));
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'username' => 'paiduser',
|
||||||
|
'email' => 'paid@example.com',
|
||||||
|
'role' => 'user', // No upgrade for paid until payment
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_registered_event_sends_welcome_email()
|
public function test_registered_event_sends_welcome_email()
|
||||||
{
|
{
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
|
|||||||
Reference in New Issue
Block a user