Skip to content

Commit

Permalink
Merge pull request #14 from kurozumi/fix
Browse files Browse the repository at this point in the history
Github Actions のプラグインのチェックアウトの参照先をプルリクエストのHEADコミットに変更
  • Loading branch information
kurozumi authored Nov 25, 2022
2 parents f0b9e8c + e12add6 commit 6a4d387
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ jobs:
composer require auth0/auth0-php
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: app/Plugin/${{ env.PLUGIN_CODE }}
ref: ${{ env.PLUGIN_BRANCH }}
ref: ${{ github.event.pull_request.head.sha }}

- name: PHPStan
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

steps:
- name: Checkout EC-CUBE
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: EC-CUBE/ec-cube
ref: ${{ matrix.eccube-versions }}
Expand Down Expand Up @@ -89,10 +89,10 @@ jobs:
composer require auth0/auth0-php
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: app/Plugin/${{ env.PLUGIN_CODE }}
ref: ${{ env.PLUGIN_BRANCH }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup EC-CUBE
run: |
Expand Down
2 changes: 1 addition & 1 deletion Controller/Admin/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function index(Request $request, CacheUtil $cacheUtil)
'OAUTH_AUTH0_CLIENT_ID' => $Config->getClientId(),
'OAUTH_AUTH0_CLIENT_SECRET' => $Config->getClientSecret(),
'OAUTH_AUTH0_CUSTOM_DOMAIN' => $Config->getCustomDomain(),
'OAUTH_AUTH0_COOKIE_SECRET' => shell_exec('openssl rand -hex 32')
'OAUTH_AUTH0_COOKIE_SECRET' => shell_exec('openssl rand -hex 32'),
]);

file_put_contents($envFile, $env);
Expand Down
4 changes: 2 additions & 2 deletions Controller/Auth0Controller.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -12,7 +13,6 @@

namespace Plugin\Auth0\Controller;


use Eccube\Controller\AbstractController;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use Plugin\Auth0\Repository\ConfigRepository;
Expand All @@ -21,14 +21,14 @@

/**
* Class Auth0Controller
* @package Plugin\Auth0\Controller
*
* @Route("/auth0")
*/
class Auth0Controller extends AbstractController
{
/**
* @param ClientRegistry $clientRegistry
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @Route("/connect", name="auth0_connect")
Expand Down
16 changes: 8 additions & 8 deletions DependencyInjection/SocialLoginExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -12,28 +13,27 @@

namespace Plugin\Auth0\DependencyInjection;


use Eccube\DependencyInjection\EccubeExtension;
use Plugin\Auth0\Security\Authenticator\Auth0Authenticator;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class SocialLoginExtension extends EccubeExtension
{
/**
* @inheritDoc
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function prepend(ContainerBuilder $container)
{
$plugins = $container->getParameter('eccube.plugins.enabled');

if(!in_array('Auth0', $plugins)) {
if (!in_array('Auth0', $plugins)) {
return;
}

Expand All @@ -42,10 +42,10 @@ public function prepend(ContainerBuilder $container)
$extensionConfigsRefl->setAccessible(true);
$extensionConfigs = $extensionConfigsRefl->getValue($container);

foreach($extensionConfigs["security"] as $key => $security) {
if(isset($security["firewalls"])) {
$extensionConfigs["security"][$key]["firewalls"]["customer"]["entry_point"] = Auth0Authenticator::class;
$extensionConfigs["security"][$key]["firewalls"]["customer"]["custom_authenticators"][] = Auth0Authenticator::class;
foreach ($extensionConfigs['security'] as $key => $security) {
if (isset($security['firewalls'])) {
$extensionConfigs['security'][$key]['firewalls']['customer']['entry_point'] = Auth0Authenticator::class;
$extensionConfigs['security'][$key]['firewalls']['customer']['custom_authenticators'][] = Auth0Authenticator::class;
}
}

Expand Down
4 changes: 4 additions & 0 deletions Entity/Config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand Down Expand Up @@ -71,6 +72,7 @@ public function getClientId(): ?string

/**
* @param string $client_id
*
* @return $this
*/
public function setClientId(string $client_id): self
Expand All @@ -90,6 +92,7 @@ public function getClientSecret(): ?string

/**
* @param string $client_secret
*
* @return $this
*/
public function setClientSecret(string $client_secret): self
Expand All @@ -109,6 +112,7 @@ public function getCustomDomain(): ?string

/**
* @param string $custom_domain
*
* @return $this
*/
public function setCustomDomain(string $custom_domain): self
Expand Down
5 changes: 3 additions & 2 deletions Entity/Connection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -12,13 +13,11 @@

namespace Plugin\Auth0\Entity;


use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\Customer;

/**
* Class Connection
* @package Plugin\Auth0\Entity
*
* @ORM\Table(name="plg_social_login_connection", uniqueConstraints={@ORM\UniqueConstraint(name="user_id", columns={"user_id", "customer_id"})})
* @ORM\Entity(repositoryClass="Plugin\Auth0\Repository\ConnectionRepository")
Expand Down Expand Up @@ -68,6 +67,7 @@ public function getUserId(): string

/**
* @param string $user_id
*
* @return $this
*/
public function setUserId(string $user_id): self
Expand All @@ -87,6 +87,7 @@ public function getCustomer(): Customer

/**
* @param Customer $Customer
*
* @return $this
*/
public function setCustomer(Customer $Customer): self
Expand Down
16 changes: 9 additions & 7 deletions Entity/CustomerTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -19,7 +20,6 @@

/**
* Class CustomerTrait
* @package Plugin\Auth0\Entity
*
* @EntityExtension("Eccube\Entity\Customer")
*/
Expand All @@ -35,7 +35,7 @@ trait CustomerTrait
*/
public function getConnections(): Collection
{
if(null === $this->Connections) {
if (null === $this->Connections) {
$this->Connections = new ArrayCollection();
}

Expand All @@ -44,15 +44,16 @@ public function getConnections(): Collection

/**
* @param Connection $connection
*
* @return $this
*/
public function addConnection(Connection $connection): self
{
if(null === $this->Connections) {
if (null === $this->Connections) {
$this->Connections = new ArrayCollection();
}

if(false === $this->Connections->contains($connection)) {
if (false === $this->Connections->contains($connection)) {
$this->Connections->add($connection);
$connection->setCustomer($this);
}
Expand All @@ -62,17 +63,18 @@ public function addConnection(Connection $connection): self

/**
* @param Connection $connection
*
* @return $this
*/
public function removeConnection(Connection $connection): self
{
if(null === $this->Connections) {
if (null === $this->Connections) {
$this->Connections = new ArrayCollection();
}

if($this->Connections->contains($connection)) {
if ($this->Connections->contains($connection)) {
$this->Connections->removeElement($connection);
if($connection->getCustomer() === $this) {
if ($connection->getCustomer() === $this) {
$connection->setCustomer(null);
}
}
Expand Down
3 changes: 2 additions & 1 deletion EventSubscriber/Admin/Customer/DeleteSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand Down Expand Up @@ -30,7 +31,7 @@ public function __construct(EntityManagerInterface $entityManager)
public static function getSubscribedEvents()
{
return [
EccubeEvents::ADMIN_CUSTOMER_DELETE_COMPLETE => 'onAdminCustomerDeleteComplete'
EccubeEvents::ADMIN_CUSTOMER_DELETE_COMPLETE => 'onAdminCustomerDeleteComplete',
];
}

Expand Down
13 changes: 6 additions & 7 deletions EventSubscriber/EntrySubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -12,7 +13,6 @@

namespace Plugin\Auth0\EventSubscriber;


use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\Customer;
use Eccube\Event\EccubeEvents;
Expand All @@ -39,34 +39,33 @@ class EntrySubscriber implements EventSubscriberInterface
public function __construct(
SessionInterface $session,
EntityManagerInterface $entityManager
)
{
) {
$this->session = $session;
$this->entityManager = $entityManager;
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
EccubeEvents::FRONT_ENTRY_INDEX_COMPLETE => 'onFrontEntryIndexComplete'
EccubeEvents::FRONT_ENTRY_INDEX_COMPLETE => 'onFrontEntryIndexComplete',
];
}

public function onFrontEntryIndexComplete(EventArgs $args)
{
$request = $args->getRequest();
if(null === $request) {
if (null === $request) {
return;
}

/** @var Customer $Customer */
$Customer = $args->getArgument('Customer');

$userInfo = $this->getUserInfoFromSession($request);
if($userInfo) {
if ($userInfo) {
$Connection = new Connection();
$Connection->setUserId($userInfo['sub']);
$Connection->setCustomer($Customer);
Expand Down
4 changes: 2 additions & 2 deletions EventSubscriber/Mypage/WithdrawSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand Down Expand Up @@ -27,11 +28,10 @@ public function __construct(EntityManagerInterface $entityManager)
$this->entityManager = $entityManager;
}


public static function getSubscribedEvents()
{
return [
EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE => 'onFrontMyPageWithdrawIndexComplete'
EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE => 'onFrontMyPageWithdrawIndexComplete',
];
}

Expand Down
9 changes: 4 additions & 5 deletions Form/Extension/EntryTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand All @@ -12,7 +13,6 @@

namespace Plugin\Auth0\Form\Extension;


use Eccube\Form\Type\Front\EntryType;
use Eccube\Form\Type\RepeatedEmailType;
use KnpU\OAuth2ClientBundle\Security\Helper\FinishRegistrationBehavior;
Expand All @@ -33,8 +33,7 @@ class EntryTypeExtension extends AbstractTypeExtension

public function __construct(
RequestStack $requestStack
)
{
) {
$this->requestStack = $requestStack;
}

Expand All @@ -44,7 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
if ($userInfo) {
$builder
->add('email', RepeatedEmailType::class, [
'attr' => ["readonly" => "readonly"]
'attr' => ['readonly' => 'readonly'],
]);

// メールアドレスをセット
Expand All @@ -57,7 +56,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function getExtendedType()
{
Expand Down
1 change: 1 addition & 0 deletions Form/Type/Admin/ConfigType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of Auth0
*
Expand Down
Loading

0 comments on commit 6a4d387

Please sign in to comment.