use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; | |||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | ||||
use Symfony\Component\Translation\TranslatableMessage; | use Symfony\Component\Translation\TranslatableMessage; | ||||
); | ); | ||||
} | } | ||||
public function changePassword(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response | |||||
public function changePassword(Request $request, UserPasswordHasherInterface $passwordEncoder): Response | |||||
{ | { | ||||
$user = $this->getUser(); | $user = $this->getUser(); | ||||
$form = $this->createForm(ChangePasswordFormType::class, $user); | $form = $this->createForm(ChangePasswordFormType::class, $user); | ||||
$plainPassword = $form->get('plain_password')->getData(); | $plainPassword = $form->get('plain_password')->getData(); | ||||
$user->setPassword($passwordEncoder->encodePassword($user, $plainPassword)); | |||||
$user->setPassword($passwordEncoder->hashPassword($user, $plainPassword)); | |||||
$this->em->update($user); | $this->em->update($user); | ||||
$this->em->flush(); | $this->em->flush(); |
<?php | <?php | ||||
namespace App\Controller\User; | |||||
namespace Lc\SovBundle\Controller\User; | |||||
use App\Entity\User\GroupUser; | |||||
use Lc\CaracoleBundle\Controller\User\GroupUserAdminController as CaracAbstractUserAdminController; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
class GroupUserAdminController extends CaracAbstractUserAdminController | |||||
abstract class GroupUserAdminController extends AbstractAdminController | |||||
{ | { | ||||
public static function getEntityFqcn(): string | |||||
{ | |||||
return GroupUser::class; | |||||
} | |||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return [ | |||||
TextField::new('title'), | |||||
TextField::new('devAlias'), | |||||
]; | |||||
} | |||||
} | } |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Model\User; | |||||
namespace Lc\SovBundle\Model\User; | |||||
interface GroupUserInterface | interface GroupUserInterface | ||||
{ | { |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Model\User; | |||||
namespace Lc\SovBundle\Model\User; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
/** | /** | ||||
*/ | */ | ||||
protected $title; | protected $title; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="groupUsers") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="groupUsers") | * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", mappedBy="groupUsers") | ||||
*/ | */ | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMerchant(): ?MerchantInterface | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?MerchantInterface $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function addUser(UserModel $user): self | |||||
public function addUser(UserInterface $user): self | |||||
{ | { | ||||
if (!$this->users->contains($user)) { | if (!$this->users->contains($user)) { | ||||
$this->users[] = $user; | $this->users[] = $user; |
namespace Lc\SovBundle\Model\User; | namespace Lc\SovBundle\Model\User; | ||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Symfony\Component\Security\Core\User\UserInterface; | use Symfony\Component\Security\Core\User\UserInterface; | ||||
*/ | */ | ||||
protected $isVerified = false; | protected $isVerified = false; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface", inversedBy="users") | |||||
*/ | |||||
protected $groupUsers; | |||||
public function getEmail(): ?string | public function getEmail(): ?string | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|GroupUserInterface[] | |||||
*/ | |||||
public function getGroupUsers(): Collection | |||||
{ | |||||
return $this->groupUsers; | |||||
} | |||||
public function addGroupUser(GroupUserInterface $groupUser): self | |||||
{ | |||||
if (!$this->groupUsers->contains($groupUser)) { | |||||
$this->groupUsers[] = $groupUser; | |||||
$groupUser->addUser($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeGroupUser(GroupUserInterface $groupUser): self | |||||
{ | |||||
if ($this->groupUsers->contains($groupUser)) { | |||||
$this->groupUsers->removeElement($groupUser); | |||||
$groupUser->removeUser($this); | |||||
} | |||||
return $this; | |||||
} | |||||
} | } |
<?php | <?php | ||||
namespace Lc\CaracoleBundle\Repository\User; | |||||
namespace Lc\SovBundle\Repository\User; | |||||
use Lc\SovBundle\Model\User\GroupUserInterface; | use Lc\SovBundle\Model\User\GroupUserInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepository; | use Lc\SovBundle\Repository\AbstractRepository; |