-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added deprecation for RememberMe services without logout() method
- Loading branch information
Showing
2 changed files
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Security\Core\Exception\LogicException; | ||
use Symfony\Component\Security\Http\Event\LogoutEvent; | ||
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface; | ||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface; | ||
|
||
/** | ||
* @author Wouter de Jong <[email protected]> | ||
|
@@ -25,13 +25,21 @@ class RememberMeLogoutListener implements EventSubscriberInterface | |
{ | ||
private $rememberMeServices; | ||
|
||
public function __construct(LogoutHandlerInterface $rememberMeServices) | ||
public function __construct(RememberMeServicesInterface $rememberMeServices) | ||
{ | ||
if (!method_exists($rememberMeServices, 'logout')) { | ||
trigger_deprecation('symfony/security-core', '5.1', '"%s" should implement the "logout(Request $request, Response $response, TokenInterface $token)" method, this method will be added to the "%s" in version 6.0.', \get_class($rememberMeServices), RememberMeServicesInterface::class); | ||
} | ||
|
||
$this->rememberMeServices = $rememberMeServices; | ||
} | ||
|
||
public function onLogout(LogoutEvent $event): void | ||
{ | ||
if (!method_exists($this->rememberMeServices, 'logout')) { | ||
return; | ||
} | ||
|
||
if (null === $event->getResponse()) { | ||
throw new LogicException(sprintf('No response was set for this logout action. Make sure the DefaultLogoutListener or another listener has set the response before "%s" is called.', __CLASS__)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
* - PersistentTokenBasedRememberMeServices (requires a TokenProvider) | ||
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
* | ||
* @method logout(Request $request, Response $response, TokenInterface $token) | ||
*/ | ||
interface RememberMeServicesInterface | ||
{ | ||
|