<?php
declare(strict_types=1);
namespace App\Controllers;

use App\Core\Auth;
use App\Core\Controller;
use App\Core\Csrf;
use App\Core\Permission;
use App\Security\MfaService;

final class MfaSettingsController extends Controller
{
    public function index(): void
    {
        Auth::requireLogin(); Permission::require('administration.permissions.view');
        $this->view('security/mfa',['pageTitle'=>'Authentification multifacteur','status'=>MfaService::status((int)Auth::id())]);
    }
    public function disable(): void
    {
        Auth::requireRecentAuthentication(); Permission::require('administration.permissions.manage'); Csrf::verify($_POST['_csrf'] ?? null);
        MfaService::disable((int)Auth::id()); Auth::logout(); $this->redirect('/login');
    }
}
