23-01-2026

This commit is contained in:
Kevin Adametz 2026-01-23 17:33:10 +01:00
parent 07959c0ba2
commit 854ce02bf6
166 changed files with 32909 additions and 1262 deletions

View file

@ -1,6 +1,7 @@
<?php
use App\Models\User;
use App\Models\RegistrationCode;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
@ -13,12 +14,25 @@ new #[Layout('components.layouts.auth')] class extends Component {
public string $email = '';
public string $password = '';
public string $password_confirmation = '';
protected ?RegistrationCode $registrationCode = null;
public function mount(): void
{
$this->loadRegistrationCode();
}
/**
* Handle an incoming registration request.
*/
public function register(): void
{
$this->loadRegistrationCode();
if (!$this->registrationCode || !$this->registrationCode->isAvailable()) {
$this->addError('registration_code', __('Registrierungscode fehlt oder ist ungültig. Bitte starten Sie über den QR-Link erneut.'));
return;
}
$validated = $this->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class],
@ -26,13 +40,36 @@ new #[Layout('components.layouts.auth')] class extends Component {
]);
$validated['password'] = Hash::make($validated['password']);
$validated['display_name'] = $this->registrationCode->name ?? null; // Name aus Registrierungscode übernehmen
event(new Registered(($user = User::create($validated))));
Auth::login($user);
// Registrierungscode als verwendet markieren
$this->registrationCode->markUsed($user);
session()->forget(['registration_code_id', 'registration_role']);
$this->redirectIntended(route('dashboard', absolute: false), navigate: true);
}
protected function loadRegistrationCode(): void
{
if ($this->registrationCode) {
return;
}
$codeId = session('registration_code_id');
$role = session('registration_role');
if (!$codeId || !$role) {
return;
}
$this->registrationCode = RegistrationCode::where('id', $codeId)
->where('role', $role)
->first();
}
}; ?>
<div class="flex flex-col gap-6">