use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use App\Domains\User\Service\TFA\TFA;
class Profile extends ControllerAbstract
{
public function __invoke(): Response|RedirectResponse
{
$this->rowAuth();
if ($response = $this->actionPost('profile')) {
return $response;
}
$this->requestMergeWithRow();
$this->meta('title', __('user-profile.meta-title'));
return $this->page('user.profile', $this->data());
}
protected function data(): array
{
return [
'row' => $this->row,
'certificate_enabled' => config('auth.certificate.enabled'),
'tfa_enabled' => ($enabled = $this->row->tfaAvailable()),
'tfa_qr' => ($enabled ? TFA::getQRCodeInline($this->row->email, $this->row->tfa_secret) : null),
];
}
protected function profile(): RedirectResponse
{
$this->action()->profile();
$this->sessionMessage('success', __('user-profile.success'));
return redirect()->route('user.profile');
}
}