vendor/pimcore/portal-engine/src/Service/Security/Authentication/User/PasswordChangeableService.php line 50

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under following license:
  6.  * - Pimcore Commercial License (PCL)
  7.  *
  8.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  9.  *  @license    http://www.pimcore.org/license     PCL
  10.  */
  11. namespace Pimcore\Bundle\PortalEngineBundle\Service\Security\Authentication\User;
  12. use Pimcore\Bundle\PortalEngineBundle\Enum\Permission;
  13. use Pimcore\Bundle\PortalEngineBundle\Event\Auth\LoginPasswordChangeableEvent;
  14. use Pimcore\Bundle\PortalEngineBundle\Service\Security\PermissionService;
  15. use Pimcore\Bundle\PortalEngineBundle\Service\Security\SecurityService;
  16. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  17. /**
  18.  * Class PasswordChangeableService
  19.  *
  20.  * @package Pimcore\Bundle\PortalEngineBundle\Service\Security\Authentication\User
  21.  */
  22. class PasswordChangeableService
  23. {
  24.     /**
  25.      * @var EventDispatcherInterface
  26.      */
  27.     private $eventDispatcher;
  28.     /**
  29.      * @var SecurityService
  30.      */
  31.     private $securityService;
  32.     /**
  33.      * @var PermissionService
  34.      */
  35.     private $permissionService;
  36.     public function __construct(EventDispatcherInterface $eventDispatcherSecurityService $securityServicePermissionService $permissionService)
  37.     {
  38.         $this->eventDispatcher $eventDispatcher;
  39.         $this->securityService $securityService;
  40.         $this->permissionService $permissionService;
  41.     }
  42.     public function isPasswordChangeable(): bool
  43.     {
  44.         $event = new LoginPasswordChangeableEvent();
  45.         if ($portalUser $this->securityService->getPortalUser()) {
  46.             $event->setPasswordChangeable($this->permissionService->isAllowed($portalUserPermission::PASSWORD_CHANGE));
  47.         }
  48.         $this->eventDispatcher->dispatch($event);
  49.         return $event->getPasswordChangeable();
  50.     }
  51. }