From 31d3f4c0760c6970abf359236e701dc8b7355583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Konvi=C4=8Dka?= Date: Mon, 10 Aug 2026 12:40:58 +0200 Subject: [PATCH] https://trello.com/c/98qWdN41/9510-001x-typeerror-nette-mail-messageaddto-argument-1-email-must-be-of-type-string-null-given-called-in-var-www-html-releases-123-ve --- .../Grids/Traits/ResetPassword/ResetPassword.php | 11 +++++++++++ src/lang/fcadmin.cs.yml | 1 + src/lang/fcadmin.sk.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/src/UI/Components/Grids/Traits/ResetPassword/ResetPassword.php b/src/UI/Components/Grids/Traits/ResetPassword/ResetPassword.php index 8fe6de3..c739ed2 100644 --- a/src/UI/Components/Grids/Traits/ResetPassword/ResetPassword.php +++ b/src/UI/Components/Grids/Traits/ResetPassword/ResetPassword.php @@ -27,10 +27,16 @@ public function injectResetPassword(): void $this['grid']->addAction('newPasswordAgain', 'Nové heslo', 'newPasswordAgain!') ->setIcon('lock') ->setConfirmation(new StringConfirmation('fcadmin.grids.user.confirms.newPassword')) + ->setRenderCondition(fn(HasIdentity $hasIdentity) => $this->getCanResetPassword($hasIdentity)) ->setClass(''); //je potreba, protoze se jinak aplikuje classa btn btn-primary atd. a prida pozadi -> skareda iknka }; } + public function getCanResetPassword(HasIdentity $hasIdentity): bool + { + return (bool) $hasIdentity->getIdentity()->getEmail(); + } + /** * @throws DateMalformedStringException * @throws InvalidArgument @@ -45,6 +51,11 @@ public function handleNewPasswordAgain(int $id): void $this->error(); } + if (!$this->getCanResetPassword($hasIdentity)) { + $this->getPresenter()->flashMessageError('fcadmin.grids.user.messages.mailErrorNoEmail'); + $this->getPresenter()->redirect('this'); + } + $identity = $hasIdentity->getIdentity(); // SSO (Keycloak) uživateli pošleme reset hesla přes Keycloak místo lokálního recovery mailu diff --git a/src/lang/fcadmin.cs.yml b/src/lang/fcadmin.cs.yml index 5a622d3..2d95491 100644 --- a/src/lang/fcadmin.cs.yml +++ b/src/lang/fcadmin.cs.yml @@ -303,6 +303,7 @@ grids: messages: mailSuccess: E-mail pro nastavení hesla byl odeslán mailError: E-mail pro nastavení hesla se nepodařilo odeslat + mailErrorNoEmail: Uživatel nemá vyplněný e-mail, výzvu pro nastavení hesla nelze odeslat. global: isActive: label: Aktivní diff --git a/src/lang/fcadmin.sk.yml b/src/lang/fcadmin.sk.yml index 9c0553e..0cf2af7 100644 --- a/src/lang/fcadmin.sk.yml +++ b/src/lang/fcadmin.sk.yml @@ -302,6 +302,7 @@ grids: messages: mailSuccess: E-mail pre nastavenie hesla bol odoslaný mailError: E-mail pre nastavenie hesla sa nepodarilo odoslať + mailErrorNoEmail: Používateľ nemá vyplnený e-mail, výzvu pre nastavenie hesla nie je možné odoslať. global: isActive: label: Aktívny