diff --git a/app/module/core/presenter/front/SecuredPresenter.php b/app/module/core/presenter/front/SecuredPresenter.php index 87635136..aa0b29cb 100644 --- a/app/module/core/presenter/front/SecuredPresenter.php +++ b/app/module/core/presenter/front/SecuredPresenter.php @@ -89,7 +89,7 @@ protected function startup(): void if ($this->getUser()->getLogoutReason() === NetteUser::LogoutInactivity) { $this->flashMessage($this->translator->translate("common.alerts.inactivityLogout")); } - $this->redirect(':Sign:In:'); + $this->redirect(':Sign:In:', ['backlink' => $this->storeRequest()]); } } diff --git a/app/module/sign/presenter/front/InPresenter.php b/app/module/sign/presenter/front/InPresenter.php index 00380092..89233739 100644 --- a/app/module/sign/presenter/front/InPresenter.php +++ b/app/module/sign/presenter/front/InPresenter.php @@ -3,8 +3,10 @@ namespace Tymy\Module\Sign\Presenter\Front; use Nette; +use Nette\Application\Attributes\Persistent; use Nette\Application\UI\Form; -use Nette\NotImplementedException; +use Nette\DI\Attributes\Inject; +use Nette\Security\AuthenticationException; use Tracy\Debugger; use Tymy\Module\Authentication\Manager\AuthenticationManager; use Tymy\Module\Core\Manager\BaseManager; @@ -13,10 +15,13 @@ class InPresenter extends BasePresenter { - #[\Nette\DI\Attributes\Inject] + #[Persistent] + public string $backlink = ''; + + #[Inject] public SignInFormFactory $signInFactory; - #[\Nette\DI\Attributes\Inject] + #[Inject] public AuthenticationManager $authenticationManager; /** @@ -29,7 +34,7 @@ protected function createComponentSignInForm(): \Nette\Application\UI\Form $this->user->setExpiration('20 minutes'); $this->user->login($values->name, $values->password); BaseManager::logg($this->team, "{$values->name} application login"); - } catch (Nette\Security\AuthenticationException $exc) { + } catch (AuthenticationException $exc) { match ($exc->getMessage()) { "Login not approved" => $this->flashMessage($this->translator->translate("common.alerts.loginNotApproved"), "danger"), default => $this->flashMessage($this->translator->translate("common.alerts.loginNotSuccesfull") . ' (' . $exc->getMessage() . ")", "danger"), @@ -39,6 +44,7 @@ protected function createComponentSignInForm(): \Nette\Application\UI\Form $this->initUser(); Debugger::log($this->tymyUser->getCallName() . "@" . $this->team->getSysName() . " logged in"); } + $this->restoreRequest($this->backlink); $this->redirect(':Core:Default:'); }); }