secret = $totp->generateSecret(); $this->qrSvg = $totp->qrCodeSvg(Auth::user(), $this->secret); } public function verify(): void { $this->validate(['code' => 'required|digits:6']); $totp = app(TotpService::class); if (!$totp->verify($this->secret, $this->code)) { $this->addError('code', 'Ungültiger Code. Bitte erneut versuchen.'); return; } $this->recoveryCodes = $totp->enable(Auth::user(), $this->secret); $this->step = 'codes'; } public function done(): void { $this->dispatch('toast', type: 'done', badge: '2FA', title: 'TOTP aktiviert', text: 'Zwei-Faktor-Authentifizierung ist jetzt aktiv.', duration: 5000); $this->dispatch('2fa-status-changed'); $this->closeModal(); } public function render() { return view('livewire.ui.system.modal.totp-setup-modal'); } }