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], 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], ]); $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(); } }; ?>
{{ __('Create account') }}
{{ __('Already have an account?') }} {{ __('Log in') }}