forked from EC-CUBE/ec-cube
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from okazy/feature/traverse-maintenance
Feature/traverse maintenance
- Loading branch information
Showing
16 changed files
with
248 additions
and
47 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of EC-CUBE | ||
* | ||
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. | ||
* | ||
* http://www.ec-cube.co.jp/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eccube\EventListener; | ||
|
||
use Eccube\Entity; | ||
use Eccube\Request\Context; | ||
use Eccube\Service\SystemService; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpFoundation\Cookie; | ||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
class MaintenanceListener implements EventSubscriberInterface | ||
{ | ||
|
||
/** @var Context */ | ||
protected $requestContext; | ||
|
||
/** @var SystemService */ | ||
protected $systemService; | ||
|
||
public function __construct(Context $requestContext, SystemService $systemService) | ||
{ | ||
$this->requestContext = $requestContext; | ||
$this->systemService = $systemService; | ||
} | ||
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
KernelEvents::RESPONSE => ['onResponse'], | ||
]; | ||
} | ||
|
||
public function onResponse(FilterResponseEvent $event) | ||
{ | ||
$response = $event->getResponse(); | ||
|
||
if (!$this->systemService->isMaintenanceMode()) { | ||
$response->headers->clearCookie(SystemService::MAINTENANCE_TOKEN_KEY); | ||
return; | ||
} | ||
|
||
$user = $this->requestContext->getCurrentUser(); | ||
if ($user instanceof Entity\Member && $this->requestContext->isAdmin()) { | ||
$cookie = new Cookie( | ||
SystemService::MAINTENANCE_TOKEN_KEY, | ||
$this->systemService->getMaintenanceToken() | ||
); | ||
$response->headers->setCookie($cookie); | ||
} | ||
} | ||
} |
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
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
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
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
43 changes: 43 additions & 0 deletions
43
src/Eccube/Security/Http/Authentication/EccubeLogoutSuccessHandler.php
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of EC-CUBE | ||
* | ||
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. | ||
* | ||
* http://www.ec-cube.co.jp/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eccube\Security\Http\Authentication; | ||
|
||
use Eccube\Request\Context; | ||
use Eccube\Service\SystemService; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Security\Http\HttpUtils; | ||
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler; | ||
|
||
class EccubeLogoutSuccessHandler extends DefaultLogoutSuccessHandler | ||
{ | ||
/** @var Context */ | ||
protected $context; | ||
|
||
public function __construct(HttpUtils $httpUtils, Context $context, $targetUrl = 'admin_login') | ||
{ | ||
parent::__construct($httpUtils, $targetUrl); | ||
$this->context = $context; | ||
} | ||
|
||
public function onLogoutSuccess(Request $request) | ||
{ | ||
$response = parent::onLogoutSuccess($request); | ||
|
||
if ($this->context->isAdmin()) { | ||
$response->headers->clearCookie(SystemService::MAINTENANCE_TOKEN_KEY); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
Oops, something went wrong.