mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
UPGRADE file updated and review changes
UPGRADE file updated and review changes fix services
This commit is contained in:
parent
530e68ea3b
commit
5d9ad1efad
6 changed files with 52 additions and 24 deletions
|
|
@ -38,6 +38,42 @@ with test or remove these services with complier pass.
|
|||
|
||||
7. The `Sylius\Component\Promotion\Event\CatalogPromotionFailed` has been removed as it is not used anymore.
|
||||
|
||||
8. Due to updating to Symfony 6 security file was changed to use the updated security system so you need to adjust your `config/packages/security.yaml` file:
|
||||
|
||||
```diff
|
||||
security:
|
||||
- always_authenticate_before_granting: true
|
||||
+ enable_authenticator_manager: true
|
||||
```
|
||||
|
||||
and you need to adjust all of your firewalls like that:
|
||||
|
||||
```diff
|
||||
admin:
|
||||
# ...
|
||||
form_login:
|
||||
# ...
|
||||
- csrf_token_generator: security.csrf.token_manager
|
||||
+ enable_csrf: true
|
||||
# ...
|
||||
new_api_admin_user:
|
||||
# ...
|
||||
- anonymous: true
|
||||
+ entry_point: jwt
|
||||
# ...
|
||||
- guard:
|
||||
# ...
|
||||
+ jwt: true
|
||||
```
|
||||
|
||||
and also you need to adjust all of your access_control like that:
|
||||
|
||||
```diff
|
||||
- - { path: "%sylius.security.admin_regex%/forgotten-password", role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
|
||||
+ - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS }
|
||||
```
|
||||
|
||||
### Asset management changes
|
||||
|
||||
We updated gulp-sass plugin as well as the sass implementation we use to be compatible with most installation
|
||||
|
|
|
|||
|
|
@ -25,18 +25,9 @@ final class TokenBasedUserContext implements UserContextInterface
|
|||
|
||||
public function getUser(): ?UserInterface
|
||||
{
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if ($token === null) {
|
||||
return null;
|
||||
}
|
||||
/** @var UserInterface|null $user */
|
||||
$user = $this->tokenStorage->getToken()?->getUser();
|
||||
|
||||
/** @var UserInterface|string|null $user */
|
||||
$user = $token->getUser();
|
||||
|
||||
if (is_string($user) || null === $user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $user;
|
||||
return $user instanceof UserInterface ? $user : null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ final class ApiCartBlamerListener
|
|||
) {
|
||||
}
|
||||
|
||||
public function onSuccessLogin(LoginSuccessEvent $loginSuccessEvent): void
|
||||
public function onLoginSuccess(LoginSuccessEvent $loginSuccessEvent): void
|
||||
{
|
||||
if (!$this->uriBasedSectionContext->getSection() instanceof ShopApiOrdersSubSection) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@
|
|||
<argument type="service" id="sylius.context.cart" />
|
||||
<argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
|
||||
<argument type="service" id="sylius.command_bus" />
|
||||
<tag name="kernel.event_listener" event="Symfony\Component\Security\Http\Event\LoginSuccessEvent" method="onSuccessLogin" />
|
||||
<tag name="kernel.event_listener" event="Symfony\Component\Security\Http\Event\LoginSuccessEvent" method="onLoginSuccess" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.listener.api_authentication_success_listener" class="Sylius\Bundle\ApiBundle\EventListener\AuthenticationSuccessListener">
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
|
||||
$this
|
||||
->shouldThrow(UnexpectedTypeException::class)
|
||||
->during('onSuccessLogin', [
|
||||
->during('onLoginSuccess', [
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -106,7 +106,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
->willReturn(new Envelope($blameCart))
|
||||
;
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -135,7 +135,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
|
||||
$cart->setCustomer(Argument::any())->shouldNotBeCalled();
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -163,7 +163,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
|
||||
$cart->setCustomer(Argument::any())->shouldNotBeCalled();
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -189,7 +189,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
$cartContext->getCart()->willThrow(CartNotFoundException::class);
|
||||
$token->getUser()->willReturn($user);
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -215,7 +215,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
$token->getUser()->shouldNotBeCalled();
|
||||
$cartContext->getCart()->shouldNotBeCalled();
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
@ -241,7 +241,7 @@ final class ApiCartBlamerListenerSpec extends ObjectBehavior
|
|||
$token->getUser()->shouldNotBeCalled();
|
||||
$cartContext->getCart()->shouldNotBeCalled();
|
||||
|
||||
$this->onSuccessLogin(
|
||||
$this->onLoginSuccess(
|
||||
new LoginSuccessEvent(
|
||||
$authenticator->getWrappedObject(),
|
||||
$passport->getWrappedObject(),
|
||||
|
|
|
|||
|
|
@ -40,13 +40,12 @@ class UniqueReviewerEmailValidator extends ConstraintValidator
|
|||
/** @var ReviewerInterface|null $customer */
|
||||
$customer = $value->getAuthor();
|
||||
|
||||
$token = $this->tokenStorage->getToken();
|
||||
if (null !== $customer) {
|
||||
if (null === $customer->getEmail()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($customer->getEmail() === $this->getAuthenticatedUserEmail($token)) {
|
||||
if ($customer->getEmail() === $this->getAuthenticatedUserEmail()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,8 +55,10 @@ class UniqueReviewerEmailValidator extends ConstraintValidator
|
|||
}
|
||||
}
|
||||
|
||||
private function getAuthenticatedUserEmail(?TokenInterface $token): ?string
|
||||
private function getAuthenticatedUserEmail(): ?string
|
||||
{
|
||||
$token = $this->tokenStorage->getToken();
|
||||
|
||||
if (null === $token) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue