forked from Somnia/SomniaRooms
Fixed Deprecations: EasyAdmin and Symfony Security
This commit is contained in:
@@ -28,18 +28,18 @@ class UserCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield TextField::new ('username');
|
yield TextField::new('username');
|
||||||
yield TextField::new ('username')->onlyWhenUpdating()->setDisabled(true);
|
yield TextField::new('username')->onlyWhenUpdating()->setDisabled(true);
|
||||||
|
|
||||||
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST', 'SuperAdmin' => 'ROLE_SUPERADMIN'];
|
$availableRoles = ['User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Test' => 'ROLE_TEST', 'SuperAdmin' => 'ROLE_SUPERADMIN'];
|
||||||
yield ChoiceField::new ('roles')
|
yield ChoiceField::new('roles')
|
||||||
->setChoices($availableRoles)
|
->setChoices($availableRoles)
|
||||||
->allowMultipleChoices(true);
|
->allowMultipleChoices(true);
|
||||||
|
|
||||||
|
|
||||||
yield FormField::addPanel('Set password')->setIcon('fa fa-key');
|
yield FormField::addFieldset('Set password')->setIcon('fa fa-key');
|
||||||
|
|
||||||
$fieldPassword = Field::new ('plainPassword', 'New password')
|
$fieldPassword = Field::new('plainPassword', 'New password')
|
||||||
->hideOnIndex()
|
->hideOnIndex()
|
||||||
->setRequired(false)
|
->setRequired(false)
|
||||||
->setFormType(RepeatedType::class)
|
->setFormType(RepeatedType::class)
|
||||||
@@ -50,7 +50,7 @@ class UserCrudController extends AbstractCrudController
|
|||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
'invalid_message' => 'The password fields do not match.',
|
'invalid_message' => 'The password fields do not match.',
|
||||||
]);
|
]);
|
||||||
if($pageName == Crud::PAGE_NEW) {
|
if ($pageName == Crud::PAGE_NEW) {
|
||||||
$fieldPassword->setRequired(true);
|
$fieldPassword->setRequired(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class UserCrudController extends AbstractCrudController
|
|||||||
{
|
{
|
||||||
$plaintextPassword = $entityInstance->getPlainPassword();
|
$plaintextPassword = $entityInstance->getPlainPassword();
|
||||||
|
|
||||||
if($plaintextPassword && $plaintextPassword != "") {
|
if ($plaintextPassword && $plaintextPassword != "") {
|
||||||
//New password set. Hash password.
|
//New password set. Hash password.
|
||||||
$hashedPassword = $this->userPasswordHasher->hashPassword($entityInstance, $plaintextPassword);
|
$hashedPassword = $this->userPasswordHasher->hashPassword($entityInstance, $plaintextPassword);
|
||||||
$entityInstance->setPassword($hashedPassword);
|
$entityInstance->setPassword($hashedPassword);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Entity;
|
|||||||
|
|
||||||
use App\Enum\UserRoleEnum;
|
use App\Enum\UserRoleEnum;
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
|
use Deprecated;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
@@ -120,6 +121,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
/**
|
/**
|
||||||
* @see UserInterface
|
* @see UserInterface
|
||||||
*/
|
*/
|
||||||
|
#[Deprecated("Not used after Symfony 7.3")]
|
||||||
public function eraseCredentials(): void
|
public function eraseCredentials(): void
|
||||||
{
|
{
|
||||||
// If you store any temporary, sensitive data on the user, clear it here
|
// If you store any temporary, sensitive data on the user, clear it here
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
|
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
|
||||||
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
|
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
|
||||||
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
|
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
|
||||||
{% if ea.crud.currentAction == 'detail' %}
|
{% if ea().crud.currentAction == 'detail' %}
|
||||||
<div class="field-icon-div d-flex gap-3">
|
<div class="field-icon-div d-flex gap-3">
|
||||||
<span title="{{ field.value }}">{{ field.formattedValue|raw }}</span>
|
<span title="{{ field.value }}">{{ field.formattedValue|raw }}</span>
|
||||||
<div class="badge text-bg-secondary">
|
<div class="badge text-bg-secondary">
|
||||||
|
|||||||
Reference in New Issue
Block a user