Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-cs-fixer を実行 #5105

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions codeception/_support/Page/Admin/CategoryManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ public function 一覧_上に($rowNum)
{
$this->tester->dragAndDropBy("body > div > div.c-contentsArea > div.c-contentsArea__cols > div.c-contentsArea__primaryCol > div > div > div > div > ul > li:nth-child($rowNum)", 0, -75);
$this->tester->wait(1);

return $this;
}

public function 一覧_下に($rowNum)
{
$this->tester->dragAndDropBy("body > div > div.c-contentsArea > div.c-contentsArea__cols > div.c-contentsArea__primaryCol > div > div > div > div > ul > li:nth-child($rowNum)", 0, 75);
$this->tester->wait(1);

return $this;
}

Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Command/ComposerRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
/* @var Command $command */
$command = $this->getApplication()->get('cache:clear');

return $command->run(new ArrayInput([
'command' => 'cache:clear',
'--no-warmup' => true,
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Controller/Admin/Product/CsvImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ private function makeProductCategory($Product, $Category, $sortNo)

/**
* @Route("/%eccube_admin_route%/product/csv_split", name="admin_product_csv_split", methods={"POST"})
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
Expand Down Expand Up @@ -1647,6 +1648,7 @@ public function splitCsv(Request $request)

/**
* @Route("/%eccube_admin_route%/product/csv_split_import", name="admin_product_csv_split_import", methods={"POST"})
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,16 @@

namespace Eccube\Controller\Admin\Setting\System;

use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Member;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\Admin\MemberType;
use Eccube\Form\Type\Admin\TwoFactorAuthType;
use Eccube\Repository\MemberRepository;
use Eccube\Service\TwoFactorAuthService;

use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class TwoFactorAuthController extends AbstractController
{
Expand Down Expand Up @@ -94,9 +85,10 @@ public function auth(Request $request)
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($Member->getTwoFactorAuthKey()) {
if ($this->twoFactorAuthService->verifyCode($Member->getTwoFactorAuthKey(),$form->get('device_token')->getData())) {
if ($this->twoFactorAuthService->verifyCode($Member->getTwoFactorAuthKey(), $form->get('device_token')->getData())) {
$response = new RedirectResponse($this->generateUrl('admin_homepage'));
$response->headers->setCookie($this->twoFactorAuthService->createAuthedCookie($Member));

return $response;
} else {
$error = trans('admin.setting.system.two_factor_auth.invalid_message__reinput');
Expand Down Expand Up @@ -126,6 +118,7 @@ public function set(Request $request)
return $this->redirectToRoute('admin_homepage');
}
$res = $this->createResponse($request);

return $res;
}

Expand All @@ -143,6 +136,7 @@ public function edit(Request $request)
if (is_array($res) && isset($res['error'])) {
$this->addError($res['error']);
}

return $res;
}

Expand All @@ -161,8 +155,7 @@ private function createResponse(Request $request)
$auth_key = $this->twoFactorAuthService->createSecret();
$builder->get('auth_key')->setData($auth_key);
$form = $builder->getForm();
}
else if ('POST' === $request->getMethod()) {
} elseif ('POST' === $request->getMethod()) {
$form = $builder->getForm();
$form->handleRequest($request);
$auth_key = $form->get('auth_key')->getData();
Expand All @@ -174,9 +167,10 @@ private function createResponse(Request $request)
$this->addSuccess('admin.setting.system.two_factor_auth.complete_message', 'admin');
$response = new RedirectResponse($this->generateUrl('admin_homepage'));
$response->headers->setCookie($this->twoFactorAuthService->createAuthedCookie($Member));

return $response;
} else {
$error = trans('admin.setting.system.two_factor_auth.invalid_message__reinput' );
$error = trans('admin.setting.system.two_factor_auth.invalid_message__reinput');
}
} else {
$error = trans('admin.setting.system.two_factor_auth.invalid_message__invalid');
Expand Down
4 changes: 1 addition & 3 deletions src/Eccube/Controller/Install/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
use Eccube\Doctrine\DBAL\Types\UTCDateTimeType;
use Eccube\Doctrine\DBAL\Types\UTCDateTimeTzType;
use Eccube\Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Eccube\Entity\Plugin;
use Eccube\Form\Type\Install\Step1Type;
use Eccube\Form\Type\Install\Step3Type;
use Eccube\Form\Type\Install\Step4Type;
use Eccube\Form\Type\Install\Step5Type;
use Eccube\Repository\PluginRepository;
use Eccube\Security\Core\Encoder\PasswordEncoder;
use Eccube\Util\CacheUtil;
use Eccube\Util\StringUtil;
Expand Down Expand Up @@ -509,7 +507,7 @@ public function complete(Request $request)
return [
'admin_url' => $adminUrl,
'is_sqlite' => strpos($databaseUrl, 'sqlite') !== false,
'token' => $token
'token' => $token,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Controller/InstallPluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public function pluginEnable(Request $request, SystemService $systemService, Plu
} else {
$pluginService->enable($Plugin);
}

} finally {
$log = ob_get_clean();
while (ob_get_level() > 0) {
Expand All @@ -121,6 +120,7 @@ public function pluginEnable(Request $request, SystemService $systemService, Plu
}

$this->cacheUtil->clearCache();

return $this->json(['success' => true, 'log' => $log]);
} else {
return $this->json(['success' => false, 'log' => $log]);
Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function page()
if (is_null($route)) {
return false;
}

return count($route->compile()->getPathVariables()) < 1;
});

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/EventListener/MaintenanceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

class MaintenanceListener implements EventSubscriberInterface
{

/** @var Context */
protected $requestContext;

Expand All @@ -49,6 +48,7 @@ public function onResponse(FilterResponseEvent $event)

if (!$this->systemService->isMaintenanceMode()) {
$response->headers->clearCookie(SystemService::MAINTENANCE_TOKEN_KEY);

return;
}

Expand Down
25 changes: 12 additions & 13 deletions src/Eccube/EventListener/TwoFactorAuthListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
namespace Eccube\EventListener;

use Eccube\Common\EccubeConfig;
use Eccube\Request\Context;
use Eccube\Entity\Member;
use Eccube\Request\Context;
use Eccube\Service\TwoFactorAuthService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class TwoFactorAuthListener implements EventSubscriberInterface
{
/**
* @var array 2段階認証のチェックを除外するroute
*/
const ROUTE_EXCLUDE = ['admin_two_factor_auth','admin_two_factor_auth_set'];
const ROUTE_EXCLUDE = ['admin_two_factor_auth', 'admin_two_factor_auth_set'];

/**
* @var EccubeConfig
Expand Down Expand Up @@ -58,11 +57,11 @@ class TwoFactorAuthListener implements EventSubscriberInterface
* @param EncoderFactoryInterface $encoderFactory
*/
public function __construct(
EccubeConfig $eccubeConfig,
EccubeConfig $eccubeConfig,
Context $requestContext,
UrlGeneratorInterface $router,
TwoFactorAuthService $twoFactorAuthService
){
) {
$this->eccubeConfig = $eccubeConfig;
$this->requestContext = $requestContext;
$this->router = $router;
Expand All @@ -87,7 +86,7 @@ public function onKernelController(FilterControllerEvent $event)
}

$route = $event->getRequest()->attributes->get('_route');
if (in_array($route,self::ROUTE_EXCLUDE)) {
if (in_array($route, self::ROUTE_EXCLUDE)) {
return;
}

Expand All @@ -99,15 +98,15 @@ public function onKernelController(FilterControllerEvent $event)
) {
// トークン入力
if ($Member->getTwoFactorAuthKey()) {
$url = $this->router->generate("admin_two_factor_auth", [], UrlGeneratorInterface::ABSOLUTE_PATH);
$url = $this->router->generate('admin_two_factor_auth', [], UrlGeneratorInterface::ABSOLUTE_PATH);
}

// 2段階認証設定
else {
$url = $this->router->generate("admin_two_factor_auth_set", [], UrlGeneratorInterface::ABSOLUTE_PATH);
$url = $this->router->generate('admin_two_factor_auth_set', [], UrlGeneratorInterface::ABSOLUTE_PATH);
}
$event->setController(function() use ($url) {
return new RedirectResponse($url, $status=302);
$event->setController(function () use ($url) {
return new RedirectResponse($url, $status = 302);
});
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Eccube/Form/EventListener/HTMLPurifierListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Eccube\Form\EventListener;


use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Eccube\Form\Extension;


use Eccube\Form\EventListener\HTMLPurifierListener;
use Eccube\Request\Context;
use Symfony\Component\Form\AbstractTypeExtension;
Expand Down
6 changes: 3 additions & 3 deletions src/Eccube/Form/Type/Admin/TwoFactorAuthType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
namespace Eccube\Form\Type\Admin;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;

class TwoFactorAuthType extends AbstractType
{
Expand All @@ -40,7 +40,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
'attr' => [
'maxlength' => 6,
'style' => 'width: 100px;'
'style' => 'width: 100px;',
],
])
->add(
Expand Down
9 changes: 5 additions & 4 deletions src/Eccube/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

use Doctrine\ORM\EntityManagerInterface;
use Eccube\Util\StringUtil;
use function explode;
use function file_exists;
use function file_get_contents;
use function file_put_contents;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use function explode;
use function file_exists;
use function file_get_contents;
use function file_put_contents;
use function unlink;

class SystemService implements EventSubscriberInterface
Expand Down Expand Up @@ -166,6 +166,7 @@ public function getMaintenanceToken(): ?string
}

$contents = file_get_contents($path);

return explode(':', $contents)[1] ?? null;
}

Expand Down