Add error message when using LoginLinkHandler outside a firewall

This commit is contained in:
Wouter de Jong 2020-10-10 17:10:29 +02:00
parent 0000dfe573
commit f807b5fc15

View File

@ -53,9 +53,14 @@ class FirewallAwareLoginLinkHandler implements LoginLinkHandlerInterface
throw new \LogicException('Cannot determine the correct LoginLinkHandler to use: there is no active Request and so, the firewall cannot be determined. Try using the specific login link handler service.'); throw new \LogicException('Cannot determine the correct LoginLinkHandler to use: there is no active Request and so, the firewall cannot be determined. Try using the specific login link handler service.');
} }
$firewallName = $this->firewallMap->getFirewallConfig($request)->getName(); $firewall = $this->firewallMap->getFirewallConfig($request);
if (!$firewall) {
throw new \LogicException('No login link handler found as the current route is not covered by a firewall.');
}
$firewallName = $firewall->getName();
if (!$this->loginLinkHandlerLocator->has($firewallName)) { if (!$this->loginLinkHandlerLocator->has($firewallName)) {
throw new \InvalidArgumentException(sprintf('No login link handler found. Did you add a login_link key under your "%s" firewall?', $firewallName)); throw new \LogicException(sprintf('No login link handler found. Did you add a login_link key under your "%s" firewall?', $firewallName));
} }
return $this->loginLinkHandlerLocator->get($firewallName); return $this->loginLinkHandlerLocator->get($firewallName);