41 lines
1004 B
PHP
41 lines
1004 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Ui\System;
|
|
|
|
use App\Services\TotpService;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
class TwoFaStatus extends Component
|
|
{
|
|
public bool $enabled = false;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->enabled = app(TotpService::class)->isEnabled(Auth::user());
|
|
}
|
|
|
|
#[On('2fa-status-changed')]
|
|
public function refresh(): void
|
|
{
|
|
$this->enabled = app(TotpService::class)->isEnabled(Auth::user());
|
|
}
|
|
|
|
public function disable(): void
|
|
{
|
|
app(TotpService::class)->disable(Auth::user());
|
|
session()->forget('2fa_verified');
|
|
$this->enabled = false;
|
|
|
|
$this->dispatch('toast', type: 'done', badge: '2FA',
|
|
title: 'TOTP deaktiviert',
|
|
text: '2FA wurde deaktiviert. Melde dich erneut an um es wieder zu aktivieren.', duration: 5000);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.ui.system.two-fa-status');
|
|
}
|
|
}
|