47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Support\OperatingMode;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
/**
|
|
* Confirmation before the operating mode changes (R23).
|
|
*
|
|
* Wortgleiches Muster zu ConfirmSaveSecret: dieses Modal mutiert nichts selbst
|
|
* — es ruft `OperatingMode::set()` nirgends auf. Bestätigen löst nur ein
|
|
* Ereignis aus, das Integrations::switchMode() auffängt; deren eigene Sperre
|
|
* (secrets.manage + kürzlich bestätigtes Passwort) bleibt die einzige Stelle,
|
|
* die tatsächlich etwas schreibt. Ein Modus, der hier gefälscht hereinkäme,
|
|
* muss trotzdem switchMode()s eigenes tryFrom() und guardSecrets() passieren.
|
|
*/
|
|
class ConfirmSwitchMode extends ModalComponent
|
|
{
|
|
public string $mode;
|
|
|
|
public function mount(string $mode): void
|
|
{
|
|
$this->authorize('secrets.manage');
|
|
|
|
// Ein Wert aus dem Aufrufort dieses Modals — dieselbe Prüfung, die
|
|
// switchMode() gleich noch einmal macht: ein unbekannter Modus 404t
|
|
// hier, statt eine Bestätigung für etwas zu zeigen, das nachher
|
|
// ohnehin still nichts tut.
|
|
abort_if(OperatingMode::tryFrom($mode) === null, 404);
|
|
|
|
$this->mode = $mode;
|
|
}
|
|
|
|
public function confirm(): void
|
|
{
|
|
$this->authorize('secrets.manage');
|
|
$this->dispatch('mode-switch-confirmed', mode: $this->mode);
|
|
$this->closeModal();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.admin.confirm-switch-mode');
|
|
}
|
|
}
|