vendor/elements/azure-auth-bundle/src/EventSubscriber/PasswordChangeSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. namespace Elements\Bundle\AzureAuthBundle\EventSubscriber;
  3. use Pimcore\Model\User;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Pimcore\Event\Model\UserRoleEvent;
  6. class PasswordChangeSubscriber implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * @return array[]
  10.      */
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             'pimcore.user.preUpdate' => [
  15.                 ['onPasswordChange'10]
  16.             ],
  17.         ];
  18.     }
  19.     /**
  20.      * @param UserRoleEvent $event
  21.      * @return void
  22.      */
  23.     public function onPasswordChange(UserRoleEvent $event)
  24.     {
  25.         $user $event->getUserRole();
  26.         if($user instanceof User){
  27.             $folder User\Folder::getById($user->getParentId());
  28.             if($folder instanceof User\Folder){
  29.                 if($folder->getName() == 'elements.at' || $folder->getName() == 'valantic.at'){
  30.                     $user->setPassword(microtime(true) . uniqid());
  31.                 }
  32.             }
  33.         }
  34.     }
  35. }