Skip to content

Commit

Permalink
Merge pull request #117 from nanasess/fix-tokenstorage
Browse files Browse the repository at this point in the history
AuthenticationCredentialsNotFoundException が発生するのを修正
  • Loading branch information
hiro-t59 authored Aug 20, 2019
2 parents 5be71a9 + a409ccf commit b427771
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist: trusty
language: php

sudo: required
Expand Down
24 changes: 20 additions & 4 deletions Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormError;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;

/**
* Class Event.
Expand Down Expand Up @@ -139,11 +140,26 @@ public function onShoppingConfirmInit(EventArgs $event)
return;
}

if ($app->isGranted('ROLE_USER')) {
$Customer = $app->user();
} else {
$Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
try {
if ($app->isGranted('ROLE_USER')) {
$Customer = $app->user();
} else {
$Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
}
} catch (AuthenticationCredentialsNotFoundException $e) {
/*
* YamatoPayment など kernel.request event で FRONT_SHOPPING_CONFIRM_INITIALIZE
* が dispatch された場合は, TokenStorage が有効になっていないため, セッションから復元する
*/
if ($app['session']->has('_security_customer')) {
$token = unserialize($app['session']->get('_security_customer'));
$app['security']->setToken($token);
$Customer = $app->user();
} else {
$Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
}
}

//check if coupon valid or not
$Coupon = $app['coupon.repository.coupon']->findActiveCoupon($CouponOrder->getCouponCd());
if (is_null($Coupon)) {
Expand Down

0 comments on commit b427771

Please sign in to comment.