diff --git a/app/Core/MujAutentifikator.php b/app/Core/MujAutentifikator.php index 0cdbd7f..37423a4 100644 --- a/app/Core/MujAutentifikator.php +++ b/app/Core/MujAutentifikator.php @@ -68,6 +68,8 @@ final class MujAutentifikator implements Nette\Security\Authenticator $twoFactor = (bool) ($row?->IS_2FA_ENABLED ?? false); // secret 2FA: $secret = (string) ($row?->TOTP_SECRET ?? null); + if (!empty($secret)) + $secret = Funkce::decrypt($secret); // je to šifra // vrátíme naši třídu UserIdentity - ta se přilepí k Userovi. return new UserIdentity( diff --git a/app/Model/UzivatelFacade.php b/app/Model/UzivatelFacade.php index 5f8b033..3b2b210 100644 --- a/app/Model/UzivatelFacade.php +++ b/app/Model/UzivatelFacade.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Model; +use App\Core\Funkce; use Nette; use Nette\Security\User; use App\Model\Login\UserIdentity; @@ -34,7 +35,7 @@ final class UzivatelFacade $this->database->table('UZIVATEL') ->get($identity->getId()) ->update([ - 'TOTP_SECRET' => $secret, + 'TOTP_SECRET' => Funkce::encrypt($secret), // šifrujeme 'IS_2FA_ENABLED' => 1 ]); } diff --git a/app/Presentation/Sign/SignPresenter.php b/app/Presentation/Sign/SignPresenter.php index e6402bc..380daf7 100644 --- a/app/Presentation/Sign/SignPresenter.php +++ b/app/Presentation/Sign/SignPresenter.php @@ -10,6 +10,7 @@ use Nette\Application\Attributes\Persistent; use Nette\Http\Session; use Nette\Http\SessionSection; use App\Model\Login\UserIdentity; +use App\Core\Funkce; final class SignPresenter extends Nette\Application\UI\Presenter { @@ -34,6 +35,9 @@ final class SignPresenter extends Nette\Application\UI\Presenter protected function createComponentSignInForm(): Form { + $sifra = Funkce::encrypt("KFMUYZL5VHCV3P5ZVFIMMPQAAN2D6ZRPBRAVATSQITDRGRKIO7P4IA3DCHLETVCMT3Y7RTXVIULC4JJSKX2JBC33XT52TLKFFPQAVAI"); + bdump($sifra); + $form = new Form(); $form->addText('username', 'Uživatelské jméno:') ->setRequired('Prosím vyplňte své uživatelské jméno.')